2
我在下面的文本字段實現UIPickerView
:如何在單個頁面中實現多個UIPickerView?
public func numberOfComponents(in pickerView: UIPickerView) -> Int{
return 1
}
public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return states.count // states is an array of strings
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return states[row]
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
textField.text = states[row]
self.view.endEditing(false)
}
我想要實現UIPickerView
另一個文本框。我應該怎麼做?我可以改變上面實施的方法來包含兩個文本字段嗎?