iOS 7:使用Modal segue&时键盘不显示autorotate == NO

时间:2014-08-22 19:39:21

标签: ios ios7 keyboard segue autorotate

(这是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];
}

1 个答案:

答案 0 :(得分:0)

固定!问题是因为我使用的是UIInterfaceOrientationPortrait而不是UIInterfaceOrientationMaskPortrait。我认为掩码是supportedInterfaceOrientations

的预期类型