UIAlertView choice causing resignFirstResponder to fail

Posted by Chazbot on Stack Overflow See other posts from Stack Overflow or by Chazbot
Published on 2011-01-13T20:48:03Z Indexed on 2011/01/13 20:53 UTC
Read the original article Hit count: 282

Filed under:
|
|
|
|

Hi everyone. I'm having a similar issue to Anthony Chan's question, and after trying every suggested solution, I'm still stuck.

Somehow, only after interacting with my UIAlertView, I'm unable to dismiss the keyboard in another view of my app. It's as though the Alert is breaking my UITextField's ability to resignFirstResponder. Below I instantiate my UIAlertView, which then calls its didDismissWIthButtonIndex method. Then, I call the showInfo method, which loads another UIViewController.

UIAlertView *emailFailAlert = [[UIAlertView alloc] initWithTitle:@"Error"
                            message:@"error message text."
                           delegate:self
                  cancelButtonTitle:@"Not now"
                  otherButtonTitles:@"Settings", nil];
[emailFailAlert setTag:2];
[emailFailAlert show];
[emailFailAlert release];

Once the 'Settings' option is pressed, I'm calling this method:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {   
    if ([alertView tag] == 2) {    
        if (buttonIndex == 1){      
            [self showInfo:nil];
        }
    }   
}

My showInfo method loads the other ViewController, via the code below:

- (IBAction)showInfo:(id)sender {
    FlipsideViewController *fscontroller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
    fscontroller.delegate = self;
    fscontroller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:fscontroller animated:YES];
    [fscontroller release];
}

Upon clicking any textField in this Flipside VC, I'm unable to dismiss the keyboard as I normally can with - (BOOL)textFieldShouldReturn:(UITextField *)textField, and [textField resignFirstResponder]. I've omitted this code bc this question is getting long, but I'm happy to post if necessary.

The interesting part is that if I comment out the [self showInfo:nil] call made when the button is clicked and call it by clicking a test button (outside the alertView didDismissWithButtonIndex: method), everything works fine. Any idea what's happening here?

Thanks in advance!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about ios