How to create picker view in Swift?

Steps to create picker view :

  1. Drag and drop picker view object in storyboard.
  2. Create IBOutlet and provide a variable name.
  3. Set <pickerView>.delegate and <pickerView>.dataSource equal to self in viewDidLoad() method.
  4. Add UIPickerViewDelegate and UIPickerViewDataSource to the view controller class declaration.
  5. Enter number of components, number of rows and title for rows in pickerview in the following function:

Leave a Reply