resignFirstResponder没有隐藏textFieldShouldReturn上的键盘 [英] resignFirstResponder not hiding keyboard on 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:
这篇关于resignFirstResponder没有隐藏textFieldShouldReturn上的键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!