Picker Views can use both a data source and a delegate. The data source sets the data that is going to be displayed in the view. The delegate object is meant to handle events, like when an item in the Picker View is selected. In this movie, see how to respond to a user's selection of an item inside a Picker view.
- [Voiceover] So, we have a pickerView…that currently holds the days of the week.…What if we wanted to respond…when an item in the pickerView was selected?…We can do that…by handling the method pickerView…didSelectRow inComponent.…This method gives us a few different things.…One, the pickerView.…Two, the row.…And then three, the component.…Now, we only have one component,…so we don't need to worry about that.…
But if we wanted to, for example,…print out the day of the week…that was selected when one is selected,…all we need to do is take the string,…add the back slash in parentheses,…and inside of the parentheses, we run days,…index, row.…And, that's going to spit out the day…that's selected in our pickerView.…I'm going to change the day…and release my mouse button.…And then when it changes, I see that day.…
Oh, that's great.…So when you want to handle…when a pickerView selects an item,…remember, this is part…of the UIPickerViewDelegate protocol.…So, your class needs to implement that protocol…by calling it out in the class declaration line.…
Interested in developing for Apple Watch or Apple TV? Get a sneak peek in Chapter 9. The course wraps up with a look at the submission process for the App Store.
- Installing Xcode and the iOS SDK
- Creating a simple iOS app
- Creating a basic interaction with a button
- Choosing an object as a first responder
- Creating a user interface with Interface Builder and Auto Layout
- Working with sliders and progress bars
- Creating views to show images and web pages
- Developing responsive layouts with size classes
- Understanding the iOS architecture
- Loading data in table views
- Transitioning between views
- Developing for the iPad, Apple Watch, and Apple TV
- Submitting apps to the App Store
Skill Level Beginner
1. Prepare to Develop an iOS App
2. Core Skills
3. Basic iOS UI
4. More UI Objects
5. Size Classes
6. iOS Application Architecture
7. Table Views
8. Multiple-View Applications
9. iPad, Watch, and Apple TV Development
10. Finish and Submit to the App Store
Next steps2m 10s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.