resignFirstResponder not hiding keyboard on textFieldShouldReturn resignFirstResponder not hiding keyboard on textFieldShouldReturn xcode xcode

resignFirstResponder not hiding keyboard on textFieldShouldReturn


I see you have the iPad tag on this. Do you happen to be presenting a modal view using UIModalPresentationFormSheet? If so, it looks like this is a limitation of the FormSheet modal presentation (either Apple is doing it intentionally for some reason, or it is a bug). See these other questions for more details:

Modal Dialog Does Not Dismiss Keyboard

Modal View Controller with keyboard on landscape iPad changes location when dismissed


There is this helpful method which allows you to dismiss the keyboard when presenting the Modal Dialog:

 - (BOOL)disablesAutomaticKeyboardDismissal { return NO; }

This will override the default behavior of the modal dialog set by Apple and allow you dismiss the keyboard. It is in the UIViewController Class.

I hope this helps someone!


If you are using the Interface Builder, look if your UITextField has the delegated linked with your class.

-Select your UITextField and in your Connections look if exits one connection in Outlets->delegate. If not, conect with you File's Owner Class.

This need to be linked with your File's Owner Class. This delegate tell where to search for a method. If your are overriding a method, you need to tell where the object will search for that.