【问题标题】:How to add Done Button to dismiss the Number Pad如何添加完成按钮以关闭数字键盘
【发布时间】:2010-06-12 06:46:46
【问题描述】:

我按照教程进行操作:
http://www.neoos.ch/news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-key

关闭数字键盘, 本教程将按钮作为子视图添加到数字键盘,

我的问题是,在同一个视图中,我也在使用文本字段输入文本,那么,如何区分数字字段和文本字段。这样我就可以相应地隐藏按钮视图。

【问题讨论】:

    标签: objective-c iphone uibutton uitextfield


    【解决方案1】:

    Yoy 可以使用 UITextFieldDelegate 协议代替 NSNotifications,并在方法 textFieldDidBeginEditing:textFieldDidEndEditing: 中检查正在使用的字段。像这样的:

    - (void) textFieldDidBeginEditing:(UITextField *)textField { 
    if (textField == self.passwordField) {
      // add subview...
    }
    

    【讨论】:

    • 这个方法没有被调用,我使用了 UITextFieldDelegate 协议。能说说原因吗,
    • 应该被调用。请确保您已将文本字段的委托出口连接到 Interface Builder 中的视图控制器。
    猜你喜欢
    • 1970-01-01
    • 2013-12-10
    • 1970-01-01
    • 2011-05-20
    • 2012-04-22
    • 1970-01-01
    • 1970-01-01
    • 2014-08-22
    • 2012-02-23
    相关资源
    最近更新 更多