我無法找到關於這件事Swift的任何方面。鍵盤在第一次點擊時顯示爲UITextField.inputView = UIPickerView
對於UITextField
,我將UIPickerView
配置爲inputView
。
一切工作正常,但是當我點擊這個特定UITextField
在第一時間,鍵盤顯示,而不是UIPickerView
,如果我再次點擊它,顯示UIPickerView
。
任何人都知道我在做什麼錯?
查看我的代碼的一些部分。
@IBAction func textFieldEditingMot(sender: UITextField) {
let motivoPicker: UIPickerView = UIPickerView()
motivos = ["Pedido de demissão","Dispensa sem justa causa","Dispensa com justa causa", "Término do contrato de experiência"]
motivoPicker.delegate = self
motivoPicker.dataSource = self
motivoTextField.inputView = motivoPicker
}
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int
{
return 1
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int
{
return motivos.count
}
func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int)
{
motivoTextField.text = motivos[row]
}
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String?
{
return motivos[row]
}
你有UITextFieldDelegate設置? –
我是新手,你能解釋我該怎麼做? –