Reputation: 1
Got a problem, cannot figure out how to use data from more than UIPickerView using didSelectRow method.
Problem is that components and rows are not separate, is there any chance to use separate rows and components?
Im trying to change label.text to some data from arrays, but it changes in other arrays even when im changing one pickerview.
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
resultLabel1.text = "\(pickerData![component][row]) \(timeNumber[row - 1]) \(timePickerData[row - 1])"
// print(component)
// print(unitsPickerView.selectedRow(inComponent: component))
// print(pickerData![component][row])
}
Upvotes: 0
Views: 24
Reputation: 116
You can you an if statement inside didSelectRow to check which UIPickerView is currently being used, then take actions accordingly. Something like:
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if pickerView == unitsPickerView {
// do stuff
} else {
// do some other stuff
}
}
Upvotes: 0