iphone - UITextfield 和 UIPickerView

标签 iphone ios ios-4.2 ios4

在我看来我有 4 个文本字段,我已经从 xib 中拖了它,

所以当我点击前三个文本字段时,我想打开一个键盘,当我只点击第四个文本字段时,我想打开一个 UIPickerView

下面我写了代码,它打开了所有文本字段的 UIPickerView..

- (void)textFieldDidBeginEditing:(UITextField *)textField{
    [textField resignFirstResponder];
    [self uiPickerPopUpDisplay];
}

所以请 friend 们帮我看看我该怎么做..

谢谢&问候 兰 git

最佳答案

使用 textFieldShouldBeginEditing: 而不是 textFieldDidBeginEditing: 方法。假设您的文本字段的名称是 textField1textField2textField3textField4。然后,在 textFieldShouldBeginEditing: 方法中。

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {

    if (textField == textField4) {

        [self uiPickerPopUpDisplay];
        return NO;
    } 

    return YES;
}

关于iphone - UITextfield 和 UIPickerView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7205322/

相关文章:

java - 客户端与服务器之间的对象传输

iphone - iPhone avTouch示例代码-模拟器未显示音频电平表

iphone - UIPopoverController 和 UINavigationController 偷工减料

iphone - 更改状态栏高度时更改 View 框架?

ios - 如何使用循环在行中仅显示 3 个按钮,在列中仅显示一个按钮

ios - Apple 示例代码中的 NavigationView

iPhone:如何/是否将我现有的私钥包含在新证书中?

ios - 如何在 Swift 中将大于 Int.max 的浮点值转换为 Int

iphone - NSDateFormatter 没有给出正确的 MMMM 值

iphone - 如何在单独的 View Controller 中从 webview 中的小图像(如 facebook)中显示全屏图像?