我有 3 个文本字段。
前两个允许使用标准键盘输入,最后一个文本字段显示一个选择器。
我在关闭键盘时遇到问题 - 因此,当单击 3 文本字段时,选择器会出现,但是前一个文本字段中的键盘仍保留在屏幕上。
我的每个文本字段都有一个标签,我正在使用以下代码:
-(void)textFieldDidBeginEditing:(UITextField *)textField { //Keyboard becomes visible
if (textField.tag == 1) {
[_textField2 resignFirstResponder];
_myPicker.hidden = true;
}
if (textField.tag == 2) {
[_textField1 resignFirstResponder];
_myPicker.hidden = true;
}
if (textField.tag == 3) {
[_textField1 resignFirstResponder];
[_textField1 resignFirstResponder];
}
}
有想法该怎么解决这个吗?