(这是iOS 7: Keyboard not showing after leaving modal ViewController的扩展)
我有一个使用HomeViewController的NavigationController。点击一个按钮,你就可以使用一个模态索引到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];
}发布于 2014-08-22 20:26:37
修好了!问题在于我使用的是UIInterfaceOrientationPortrait而不是UIInterfaceOrientationMaskPortrait。我认为口罩是supportedInterfaceOrientations所期望的类型
https://stackoverflow.com/questions/25454425
复制相似问题