I want to be able to dismiss the iPhone keyboard when the user taps anywhere outside of the keyboard. How can I go about doing this? I know I need to dismiss the responder, but need to know how to implement it when a user taps out of the keyboard space.
Share
You’ll need to add an
UITapGestureRecogniserand assign it to the view, and then call resign first responder on the textfield on it’s selector.The code:
In
viewDidLoadIn
dismissKeyboard:(Where aTextField is the textfield that is responsible for the keyboard)
OPTION 2
If you can’t afford to add a gestureRecognizer then you can try this