I am writing an if statement for an ios app and I want change the picker, based on which text field currently has focus. here is what I have so far.
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
if (condition) {
return array1.count
}else{
return array2.count
}
}
func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if (condition) {
textBox1.text = array1[row]
}else{
textBox2.text = array2[row]
}
}
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
if (condition) {
return array1[row]
}else{
return array2[row]
}
}
Aucun commentaire:
Enregistrer un commentaire