Victor17 Victor17 - 1 year ago 104
Swift Question

Displaying a Picker View selection in another ViewController in Swift

I am fairly new to Swift and am trying to have the item I select in my picker view display on a label on another screen. I know that when I want pass data from one page to another I need to use the prepareForSegue function but I cant figure out how to pass data from a picker view.

Answer Source

You can implement the UIPickerViewDelegate and UIPickerViewDataSource protocols to get data from the picker view.

If you're just using it as an input for a text field, you can simply just set textField.inputView = pickerView instead of having the picker view on another controller.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download