Dismiss keyboard when touching outside of UITextField in IOS?

Posted by Ramesh Singh | Updated on

In this example, dismiss keyboard when touching outside of UITextField in IOS. You’ll need to add an UITapGestureRecogniser and assign it to the view, and then call resign first responder on the UITextField on it’s selector.

In viewDidLoad

In dismissKeyboard:

Swift 3 version looks like that.

For dismissKeyboard


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers