Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPad popover textfield - resignFirstResponder doesn't dismiss keyboard

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;
}
like image 701
mosdev Avatar asked Apr 16 '10 16:04

mosdev


3 Answers

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;
}
like image 121
aslisabanci Avatar answered Nov 18 '22 06:11

aslisabanci


As described in this answer, the keyboard will sometimes remain on-screen when the view is presented with the UIModalPresentationFormSheet style.

like image 2
Lachlan Roche Avatar answered Nov 18 '22 06:11

Lachlan Roche


I'm not too sure about this, but, as I understand the responder hierarchy, resign would work only if you have some other responder to answer.

In a regular view, the view itself is willing. In a popup, maybe you need to do something to your popup class (like reimplement some Responder methods) in order for this to work.

like image 1
jv42 Avatar answered Nov 18 '22 06:11

jv42