iOS 8.3键盘方向错误

ult*_*gtx 6 keyboard orientation ios

我正面临一个奇怪的iOS 8.3问题,它显示键盘的方向错误(视图控制器处于横向模式,但键盘显示在纵向模式):

视图控制器处于横向模式,但键盘以纵向模式显示

我可以通过以下步骤触发此问题:

  1. 创建2 UIViewController个子类:ViewControllerAViewControllerB

  2. ViewControllerA实施supportedInterfaceOrientations和返回UIInterfaceOrientationMaskPortrait

  3. ViewControllerB实施supportedInterfaceOrientations和返回UIInterfaceOrientationMaskLandscape

  4. 创建一个UINavigationController名为NavigationController,实现supportedInterfaceOrientations和返回的子类[self.topViewController supportedInterfaceOrientations](我这样做是因为我想保持NavigationController并且它的rootVC不能旋转)

  5. 使用NavigationController应用程序的初始视图控制器,设置ViewControllerANavigationController'srootViewContrller

  6. 启动应用程序,ViewControllerA将显示在Portrait中.显示一个按钮ViewControllerA,按下按钮将显示ViewControllerB使用presentViewController:animated:completion

  7. ViewControllerB将出现在风景中; 显示文本字段ViewControllerB,点击文本字段将触发键盘,但键盘处于纵向模式,就像上面的图像一样.

PS.您可以在github上下载并运行Xcode项目

此问题似乎只出现在iOS 8.3上.难道我做错了什么 ?或许这只是iOS的另一个错误?

顺便说一句,如果你只是ViewControllerA直接显示没有a ,这个问题就不会发生ViewController.因此,如果这是iOS的错误,我怎么能避免子类化,UINavigationController但仍然保留ViewControllerA哪个是UINavigationController旋转的rootViewController .


更新:此错误仍然出现在iOS 8.4上,我在2015年6月17日发布了一个错误报告,并得到了苹果的回复,他们表示已经在最新的iOS 9测试版中解决了这个问题.

小智 2

我们通过欺骗设备让它认为它已旋转到不同的方向,然后再旋转到其预期方向来解决这个问题。

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    self.segmentedControl.selectedSegmentIndex = 0;
    if(!self.rotatingForDismissal)
    {
        [self.tableNumberTextField becomeFirstResponder];
    }


    if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.3"))
    {
        [[UIDevice currentDevice] setValue:@(UIDeviceOrientationLandscapeLeft) forKey:@"orientation"];
        [[UIDevice currentDevice] setValue:@(self.interfaceOrientation) forKey:@"orientation"];
    }

}
Run Code Online (Sandbox Code Playgroud)