我有一个 UITextField View ,当按下返回时它应该隐藏键盘。
我的功能是这样的:
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
if ( textField == userPassword ) {
[textField resignFirstResponder];
}
return YES;
}
通常键盘应该被隐藏,但它会留在屏幕上。 resignFirstResponder 被正确调用。我错过了什么?
最佳答案
我看到你上面有 iPad 标签。您是否碰巧使用 UIModalPresentationFormSheet 呈现模态视图?如果是这样,看起来这是 FormSheet 模式表示的限制(Apple 出于某种原因故意这样做,或者它是一个错误)。有关更多详细信息,请参阅这些其他问题:
Modal Dialog Does Not Dismiss Keyboard
Modal View Controller with keyboard on landscape iPad changes location when dismissed
关于xcode - resignFirstResponder 没有在 textFieldShouldReturn 上隐藏键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3124828/