

For this technique I am going to assume that you already have a text field setup.īefore we can add the delegate method to our view controller, we need to adopt the UITextFieldDelegate. NOTE: This will not work on a UITextView because we are using the UITextFieldDelegate and the UITextViewDelegate does not have this functionality. This to me feels dirty but there are ways that one can clean it up.

In order to use the return key, we need to adopt the UITextFieldDelegate which requires us to set the delegate of each text field that we use in our view.

Some techniques are better than others, but it depends on your use case. In this tutorial I will go through a few techniques that you can use to dismiss the keyboard in your app. For a custom keyboard that is specific to a single app, create a view and assign the view to UITextField.inputView: textField. Dismissing the keyboard in iOS is something that almost every app will need to do at some point if it has a UITextField or UITextView.
