iPad popover textfield - resignFirstResponder不会关闭键盘 [英] iPad popover textfield - resignFirstResponder doesn't dismiss keyboard

查看:339
本文介绍了iPad popover textfield - resignFirstResponder不会关闭键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文本字段的电子邮件和密码。当在常规视图上显示字段时,以下代码可以正常工作,但是当它们在弹出窗口上时,resignFirstResponder不起作用(becomeFirstResponder工作)。两个字段都调用了textFieldsShouldReturn。
如果我错过了什么,有什么想法吗?
谢谢!

I have two text fields email and password. The following code works fine when the fields are presented on a regular view but when they are on a popover, the resignFirstResponder does not work (becomeFirstResponder works). textFieldsShouldReturn was called for both fields. Any idea if I am missing something? Thanks!

  - (BOOL)textFieldShouldReturn:(UITextField *)theTextField {

     if (theTextField == email) {
         [password becomeFirstResponder];
         return NO;
     }

     [theTextField resignFirstResponder];
     return NO;
}


推荐答案

检查这个问题:

覆盖 disablesAutomaticKeyboardDismissal 返回,如下所示修复了我的同样问题。您应该将此代码放入视图控制器,从中启动键盘:

Overriding disablesAutomaticKeyboardDismissal to return NO as below fixed the same problem of mine. You should put this code to your view controller, from which you initiate the keyboard:

- (BOOL)disablesAutomaticKeyboardDismissal {
    return NO;
}

这篇关于iPad popover textfield - resignFirstResponder不会关闭键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆