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
From the course: iOS 17 Development Essential Training
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Choosing between SwiftUI and storyboards2m 15s
-
(Locked)
Drag and drop user interface creation with storyboards4m 12s
-
(Locked)
Change a label's text at runtime4m 43s
-
(Locked)
Handling a button press2m 32s
-
(Locked)
Using text gathered from text fields4m 21s
-
(Locked)
Showing the software keyboard2m 2s
-
(Locked)
Dismissing the software keyboard2m 41s
-
(Locked)
Troubleshoot common UI problems5m 26s
-
(Locked)
Working with pins4m 25s
-
(Locked)
Troubleshooting pins5m 13s
-
(Locked)
Challenge: Storyboards46s
-
(Locked)
Solution: Storyboards3m 29s
-
-
-
-
-