iPad popover textfield - resignFirstResponder doesn't dismiss keyboard

mosdev picture mosdev · Apr 16, 2010 · Viewed 9.1k times · Source

I have two text fields email and password. The following code works fine when the fields are presented on a regular view but when they are on a popover, the resignFirstResponder does not work (becomeFirstResponder works). textFieldsShouldReturn was called for both fields. Any idea if I am missing something? Thanks!

  - (BOOL)textFieldShouldReturn:(UITextField *)theTextField {

     if (theTextField == email) {
         [password becomeFirstResponder];
         return NO;
     }

     [theTextField resignFirstResponder];
     return NO;
}

Answer

aslisabanci picture aslisabanci · Nov 29, 2011

Check this question:

Overriding disablesAutomaticKeyboardDismissal to return NO as below fixed the same problem of mine. You should put this code to your view controller, from which you initiate the keyboard:

- (BOOL)disablesAutomaticKeyboardDismissal {
    return NO;
}