resignFirstResponder 无法在模态视图控制器中工作
我在使用 UIModalPresentationFormSheet 显示的视图中放弃键盘时遇到问题。当我使用 UIModalPresentationPageSheet 时,它工作正常(键盘隐藏)。这是我非常简单的代码,它显示模式视图,一个在表单中,一个在页面表中。
- (void)showModalWithFormSheet:(BOOL)formSheet {
testViewController *test = [[testViewController alloc] initWithNibName:nil bundle:nil];
test.modalPresentationStyle = formSheet ? UIModalPresentationFormSheet : UIModalPresentationPageSheet;
[self presentModalViewController:test animated:YES];
[test release];
}
这是一个退出响应者的 textField 委托。
- (BOOL)textFieldShouldReturn:(UITextField *)t {
[t resignFirstResponder];
return YES;
}
相同的代码,但当以表单形式呈现时,我无法隐藏键盘(调用 resignFirstResponder 后)。我在模拟器和设备上都尝试过这个。任何帮助将不胜感激,这完全让我发疯!很难相信这个问题以前没有被提出过,我是不是错过了什么?
谢谢莹
I'm having an issue with resigning the keyboard in a view that is shown using UIModalPresentationFormSheet. It works fine(keyboard hides) when I use UIModalPresentationPageSheet. Here is my very simple code that brings up the modal view, one in form sheet, and one in page sheet.
- (void)showModalWithFormSheet:(BOOL)formSheet {
testViewController *test = [[testViewController alloc] initWithNibName:nil bundle:nil];
test.modalPresentationStyle = formSheet ? UIModalPresentationFormSheet : UIModalPresentationPageSheet;
[self presentModalViewController:test animated:YES];
[test release];
}
Here is a textField delegate that resigns the responder.
- (BOOL)textFieldShouldReturn:(UITextField *)t {
[t resignFirstResponder];
return YES;
}
Identical code, but when presented as a formsheet, i cannot get the keyboard to hide(after resignFirstResponder is called). I tried this on both simulator and device. Any help would be appreciated, this is totally driving me insane! Its hard to believe that this question has not been brought up before, am i missing something?
Thanks
Ying
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此处回答。只是你下面的一些帖子。
Answered here. Just some posts under yours.