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

查看:283
本文介绍了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天全站免登陆