【问题标题】:UITextView didEndEditing isn't called on iPad在 iPad 上未调用 UITextView didEndEditing
【发布时间】:2011-11-22 23:22:43
【问题描述】:

当您在 iPad 上使用按钮右上角的按钮关闭键盘时,不会调用方法 textViewDidEndEditing。但是,我希望调用该方法,以便我基本上可以访问书面文本。

有什么建议吗?

【问题讨论】:

    标签: ios ipad keyboard uitextview dismiss


    【解决方案1】:

    关注UIKeyboardDidHideNotification:

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardDidHide:) 
                                                 name:UIKeyboardDidHideNotification 
                                               object:nil];
    
    - (void)keyboardDidHide:(NSNotification *)note {
        // Whatever you want
    }
    

    不要忘记在dealloc 中致电removeObserver:

    - (void)dealloc {
      [[NSNotificationCenter defaultCenter] removeObserver:self];
      [super dealloc];
    }
    

    【讨论】:

    • 我也有一个textField,它的方法textFieldShouldReturn不再起作用了……有什么解决办法吗?感谢您的回答。
    • 这听起来像是一个完全不同的问题。完成这个并打开一个新问题,其中包含有关您的 texField 的详细信息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多