From the course: iOS 17 Development Essential Training

Unlock this course with a free trial

Join today to access over 24,000 courses taught by industry experts.

Dismissing the software keyboard

Dismissing the software keyboard

- [Instructor] So we've looked at presenting the keyboard programmatically, but what about dismissing the keyboard programmatically? As you may guess, we simply call the opposite method of becomeFirstResponder, which is resignFirstResponder. Let's take a look at adding that in the buttonWasPressed method. So go at the bottom there and then type textField.resignFirstResponder. Notice in the description that this notifies the object that has been asked to relinquish its status as first responder in its window. So I'll press Return to fill that in, and then run the app and see what happens. So again, when I launched the app, the software keyboard shows. You may have noticed if you used your hardware keyboard to type in here that the software keyboard is dismissed. That's actually a feature of iOS. Once a hardware keyboard is detected, iOS decides not to use the software keyboard. What you need to do is use the software…

Contents