I find same case for one pickerView
, I will say same words like below:
I have a pickerView
that pops up when a textField
is clicked inside. The user selects their location in the pickerView
, and it's put into the textField
.
When opening the pickerView
, the slider is on the first element, but if I click the done button to minimize the pickerView
, that no element is selected (i.e. you must scroll down and back up to select the first element)
I can make for a textField
and a pickerView
. But I have 3 textFields and 3 pickerViews. Can I do for every pickerView
?
Below code block, works for one.
func textFieldDidBeginEditing(_ textField: UITextField) {
if textField == yourTextField {
self.yourPickerView.selectRow(0, inComponent: 0, animated: true)
self.pickerView(yourPickerView, didSelectRow: 0, inComponent: 0)
}
}
How you described in comment, you want to start editing textField when user click to specific textField if text of previous textField isn't empty. So use
textFieldShouldBeginEditing
delegate method like this:Then, when textField begin editing show specific pickerView
and then when user select row you want to change text in textField