Expected behaviour:
user clicks inside TextField1
, the keyboard pops up, user enters a value, NextButton
is pressed, keyboard should be dismissed.
Anomaly: the keyboard gets dismissed upon pressing NextButton
, however it then pops up again after the alerts that follow are dismissed! Why?
On the other hand, if the alert is never called (//[self showDisclaimer]
) the keyboard gets dismissed correctly...
I know that alertView
is deprecated, but this is not the source of the error, because I get exactly the same behaviour if I use UIAlertController
instead.
Can someone shed some light on this?
- (IBAction) NextButton: (id) sender
{
[self backgroundTouch:id]; //Dismisses the keyboard
[self showDisclaimer];
}
- (void) showDisclaimer {
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Disclaimer" message: @"bla bla bla"
delegate:self
cancelButtonTitle: nil
otherButtonTitles:@"Don't agree", @"I AGREE", nil];
[alertView show];
}
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"I AGREE"])
{
[self showAlert];
}
else if([title isEqualToString:@"Don't agree"])
{
//Do something else
}
}
- (IBAction) backgroundTouch: (id)sender {
[TextField1 resignFirstResponder];
}