(这是iOS 7: Keyboard not showing after leaving modal ViewController)
的扩展我有HomeViewController
使用NavigationController
。单击按钮会使用模态segue转到ModalViewController
。按后退按钮然后返回HomeViewController
,然后弹出键盘。奇怪的是,键盘永远不会出现。我已经确认UIKeyboardDidShowNotification
被解雇了,UIKeyboardDidHideNotification
没有,[textfield isFirstResponder]
返回true。这意味着键盘应该正确显示??
我已经确认只有在我有模态segue且NavigationController::shouldAutorotate
返回NO
时才会出现这种情况。
我已复制下面的相关代码。任何帮助将不胜感激!!
NavigationController.m:
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationPortrait;
}
HomeViewController.m:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if (firstTimeComplete) {
UITextField *textField = [[UITextField alloc] init];
[self.view addSubview:textField];
[textField performSelector:@selector(becomeFirstResponder) withObject:nil afterDelay:3];
}
}
ModalViewController.m:
- (IBAction)back:(id)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}
答案 0 :(得分:0)
固定!问题是因为我使用的是UIInterfaceOrientationPortrait
而不是UIInterfaceOrientationMaskPortrait
。我认为掩码是supportedInterfaceOrientations