tags:

views:

32

answers:

1

hi friends .. i am facing a problem in resigning the keyboard. i have a tableViewController in a navigation controller and a different view controller is pushed to the navigation controller on selection of one of the cell. in the view controller i have assigned a textfield as the first responder so that the keyboard shows up as soon as viewcontroller is pushed and the keyboard is resigned while poping the viewcontroller

  • (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { [self.navigationController popViewControllerAnimated:YES];

}

  • (void)viewWillDisappear:(BOOL)animated{ [self.textField resignFirstResponder]; }

this is working fine when. But again when i push the same view controller and when i pop it the keyboard is not resigning.It is blocking the view of the tableViewController. i cant make out what actually i have went wrong .. any help Please....

A: 

Hi Praseed,

I had the same problem than you with the same context (UINavigationController, UIAlertView, UITextField or UITextView).

I solved this problem easily by executing the pop in background and remove the resignFirstResponder call (viewWillDisappear method in your file) like this :

-(void)popCurrentView {
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
    if (alertView.cancelButtonIndex != buttonIndex) {
        [self performSelectorInBackground:@selector(popCurrentView) withObject:nil]; 
    }
}
quicky