The keyboard can be dismissed in multiple ways, one of which is through delegation. Delegation is how many iOS objects handle events—the object that triggers the event notifies the delegate that the event occurred and the delegate handles the event. Learn more in this movie.
- [Instructor] Another important concept in IOS development,…is called delegation.…Delegation is where one object delegates…the handling of its events to another object.…Now that may sound kind of complicated,…but let me show you how it works.…Imagine in our app, that we want to dismiss the keyboard…when we press the Return key.…Pressing the return key on the software keyboard,…actually sends an event through the text field,…which can be handled through its delegate.…
To set that up, you need to do a couple of things first.…First we need to identify our current class,…as a class that can handle certain delegate methods.…So if we want to handle the delegate methods…for a text field,…then we need to flag this class as being able to do that.…And we do that after the declaration of the subclass,…so on line 11 in the code, we see the class declaration…with the name of the class, which is ViewController,…and this colon that says ViewController is a subclass of,…in other words it inherits all the features of,…UIViewController, the class built into IOS.…
- Installing Xcode and the iOS SDK
- Creating layouts
- Adding interactions
- Changing labels and text fields
- Troubleshooting UI-to-code connections