resignFirstResponder 没有在 textFieldShouldReturn 上隐藏键盘 [英] resignFirstResponder not hiding keyboard on textFieldShouldReturn

查看:29
本文介绍了resignFirstResponder 没有在 textFieldShouldReturn 上隐藏键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UITextField 视图,当按下返回键时,它应该隐藏键盘.

I have a view with a UITextField which should hide the keyboard when return is pressed.

我的功能是这样的:

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
 if ( textField == userPassword ) {
  [textField resignFirstResponder];
 }
 return YES;
}

通常应该隐藏键盘,但它会保留在屏幕上.resignFirstResponder 被正确调用.我错过了什么?

Normally the keyboard should be hidden but it stays on the screen. resignFirstResponder is correctly called. What am I missing?

推荐答案

我看到你在这上面有 iPad 标签.您是否碰巧使用 UIModalPresentationFormSheet 呈现模态视图?如果是这样,看起来这是 FormSheet 模式演示的限制(Apple 出于某种原因有意这样做,或者它是一个错误).有关更多详细信息,请参阅这些其他问题:

I see you have the iPad tag on this. Do you happen to be presenting a modal view using UIModalPresentationFormSheet? If so, it looks like this is a limitation of the FormSheet modal presentation (either Apple is doing it intentionally for some reason, or it is a bug). See these other questions for more details:

模态对话框不会关闭键盘

横向 iPad 上带键盘的模态视图控制器在关闭时更改位置

这篇关于resignFirstResponder 没有在 textFieldShouldReturn 上隐藏键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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