【问题标题】:iOS 7: Keyboard not showing when using Modal segue & autorotate == NOiOS 7:使用 Modal segue & autorotate 时键盘不显示 == NO
【发布时间】:2014-10-16 17:52:55
【问题描述】:

(这是iOS 7: Keyboard not showing after leaving modal ViewController的扩展)

我有一个使用NavigationControllerHomeViewController。单击一个按钮会将您带到ModalViewController 使用模态segue。按下后退按钮,您将返回HomeViewController,然后弹出一个键盘。奇怪的是键盘从来没有出现过。我已经验证了 UIKeyboardDidShowNotification 确实被解雇了,UIKeyboardDidHideNotification 没有,[textfield isFirstResponder] 返回 true。这意味着应该正确显示键盘??

我已经验证,只有当我有模态转场并且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];
}

【问题讨论】:

    标签: ios ios7 keyboard segue autorotate


    【解决方案1】:

    已修复!问题是因为我使用的是UIInterfaceOrientationPortrait 而不是UIInterfaceOrientationMaskPortrait。我认为面具是supportedInterfaceOrientations 的预期类型

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-15
      • 2020-03-17
      • 1970-01-01
      • 2015-09-09
      • 1970-01-01
      • 2017-07-09
      • 1970-01-01
      • 2012-11-19
      相关资源
      最近更新 更多