【问题标题】:Fatal Exception: UIApplicationInvalidInterfaceOrientation致命异常:UIApplicationInvalidInterfaceOrientation
【发布时间】:2015-08-13 06:48:03
【问题描述】:

我的应用在上线后和从 Crashlytics 日志中崩溃,我可以看到如下崩溃详细信息

致命异常:UIApplicationInvalidInterfaceOrientation 支持的方向与应用程序没有共同方向,并且 [UIAlertController shouldAutorotate] 返回 YES

我有类似下面的代码

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

我发现这种崩溃只发生在 iOS 8.3 和 8.4 中。有任何想法吗?谢谢!

【问题讨论】:

    标签: ios objective-c iphone


    【解决方案1】:

    您是否检查过目标设备的方向设置?

    【讨论】:

    • 是的,我选择了所有选项
    • 那么指定一个特定的视图控制器只有横向旋转吗?或者您希望整个应用程序在各个方向都可用?
    • 我指定一个视图控制器是横向的,其他是纵向的
    【解决方案2】:

    在每个视图控制器中,无论是横向还是纵向,都覆盖这三个函数:

    - (BOOL)shouldAutorotate {
        return YES;
    }
    
    - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
        return UIInterfaceOrientationMaskPortrait;
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
        return UIInterfaceOrientationPortrait;
    }
    

    注意 shouldAutorotateToInterfaceOrientation: 在 iOS 6 中已被弃用,并且自 iOS 6 或 7 起不再被调用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-16
      • 2017-09-13
      • 2012-07-23
      • 2016-06-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多