在我看来我有 4 个文本字段,我已经从 xib 中拖了它,
所以当我点击前三个文本字段时,我想打开一个键盘,当我只点击第四个文本字段时,我想打开一个 UIPickerView
下面我写了代码,它打开了所有文本字段的 UIPickerView..
- (void)textFieldDidBeginEditing:(UITextField *)textField{
[textField resignFirstResponder];
[self uiPickerPopUpDisplay];
}
所以请 friend 们帮我看看我该怎么做..
谢谢&问候 兰 git
最佳答案
使用 textFieldShouldBeginEditing:
而不是 textFieldDidBeginEditing:
方法。假设您的文本字段的名称是 textField1
、textField2
、textField3
、textField4
。然后,在 textFieldShouldBeginEditing: 方法中。
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
if (textField == textField4) {
[self uiPickerPopUpDisplay];
return NO;
}
return YES;
}
关于iphone - UITextfield 和 UIPickerView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7205322/