0
0
iOS Swiftmobile~5 mins

Picker and DatePicker in iOS Swift - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a UIPickerView used for in iOS development?
A UIPickerView lets users select a value from a list by spinning a wheel-like interface. It's like choosing an option from a rotating menu.
Click to reveal answer
beginner
How does UIDatePicker help users in an app?
UIDatePicker lets users pick dates and times easily using a familiar scrolling wheel or calendar style. It simplifies entering date/time information.
Click to reveal answer
intermediate
Which protocol must a class conform to for providing data to a UIPickerView?
The class must conform to <code>UIPickerViewDataSource</code> to provide the number of components and rows, and <code>UIPickerViewDelegate</code> to provide the content and handle selection.
Click to reveal answer
intermediate
What property of UIDatePicker controls whether it shows date, time, or both?
The datePickerMode property controls the display mode. It can be set to .date, .time, or .dateAndTime.
Click to reveal answer
intermediate
How can you respond when a user changes the selected value in a UIPickerView?
Implement the delegate method pickerView(_:didSelectRow:inComponent:). This method is called whenever the user picks a new row.
Click to reveal answer
Which method provides the number of rows in a UIPickerView component?
ApickerView(_:didSelectRow:inComponent:)
BpickerView(_:titleForRow:forComponent:)
CpickerView(_:numberOfRowsInComponent:)
DnumberOfComponents(in:)
What property of UIDatePicker sets it to show only time?
Amode = .date
Bmode = .dateAndTime
CpickerMode = .time
DdatePickerMode = .time
Which delegate method is called when a user selects a new row in UIPickerView?
ApickerView(_:didSelectRow:inComponent:)
BpickerView(_:titleForRow:forComponent:)
CpickerView(_:numberOfRowsInComponent:)
DpickerView(_:viewForRow:forComponent:reusing:)
How many components does a basic UIPickerView usually have?
AThree
BOne
CTwo
DZero
Which class is used to let users pick dates and times in iOS?
AUIDatePicker
BUIPickerView
CUITableView
DUICollectionView
Explain how to set up a UIPickerView to show a list of options and respond when the user picks one.
Think about how you tell the picker what to show and how to react when the user spins the wheel.
You got /4 concepts.
    Describe how to configure a UIDatePicker to let users pick only a date, and how to get the selected date.
    Focus on the mode property and how to listen for changes.
    You got /3 concepts.