Picker views trigger an event when their value changes. In this video, see how to respond to that event and how to get data from the picker view about what is selected.
- [Instructor] So let's say you want to handle…whenever a row is selected in your pickerView.…So, before we write any code for that,…I wanted to create a user interface element…that will display the selected row.…So let's show the navigator and the utilities area…and head over to our storyboard.…And in here, I'm going to filter…for a label in the object library.…And then just click and drag one out below our picker.…Right about there should be fine.…And I want it to be a little bit bigger than it is now…so I'm going to click and drag the handles…to expand it horizontally.…
That should be good.…We're going to center the label using…the Alignment button inside of the Attributes inspector.…So I'll center it right there.…And then I want to just drag it to follow the guides…to be right in the middle.…That looks good.…I'll just use Shift-Option-Command equals…to create those auto layout pins.…The next step is to connect the label to our code.…So, again, my favorite method for doing this…is option-clicking the code file…
Instructor Todd Perkins shows how to use pickers, pop-up messages, sliders, switches, and indicators to build a sophisticated app interface, and display HTML content, files, and data with web views. Plus, learn how to dynamically update your layouts using size classes, and get a brief overview of the Apple Human Interface Guidelines.
- Picker views, controllers, sliders, and indicators
- Creating UI elements with code
- Displaying images with image views
- Creating web views to display web content
- Changing fonts, pins, and views with size classes