ios - 横向应用程序中的 GameCenter 身份验证抛出 UIApplicationInvalidInterfaceOrientation

标签 ios orientation ios6 landscape game-center

问题: 如果用户未登录 GameCenter 帐户 - GameCenter 身份验证 View 以纵向模式启动(在 ios 5 中有一个模态对话框)要求登录。但是如果我在 xcode(项目摘要)或 supportedInterfaceOrientationsForWindow 中禁用纵向模式:(如我的应用程序应该只在横向模式下运行)我得到:

由于未捕获的异常“UIApplicationInvalidInterfaceOrientation”而终止应用程序,原因:“支持的方向与应用程序没有共同的方向,shouldAutorotate 返回 YES”

如果我为 ipad/iphone 启用肖像(和/或注释掉 supportedInterfaceOrientationsForWindow:) 它可以正常工作而不会崩溃,但我不想启用肖像模式。

最佳答案

在写这个问题和尝试代码时,我似乎找到了解决方案: 在项目摘要中启用所有方向并删除 application:supportedInterfaceOrientationsForWindow。

将此代码添加到 ViewController:

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

现在它可以无缝运行。

关于ios - 横向应用程序中的 GameCenter 身份验证抛出 UIApplicationInvalidInterfaceOrientation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12427979/

相关文章:

ios - 我可以通过 iPad 上的 PhoneGap 应用程序通过电子邮件发送文件吗?

iOS - iOS 8 中的 UIAlertView/UIAlertController 方向问题

iOS UIButton 在将背景图像设置为 nil 后消失

ios - 在 Storyboard中支持 UIViewController 的纵向方向模式

iOS 应用程序无法在设备上编译,但在模拟器中运行良好

ios - SwiftUI ActionSheet 每个 Action 的不同颜色

ios - UIImageView 约束为 1 :1 aspect ratio and 1:1 scaled to original?

android - 如何获得相对于设备主体的 Activity 的真实旋转

Android 使用传感器获取设备方向

ios - 有没有办法在 iOS 平台上的 NativeScript 应用程序中捕获和取消后退按钮事件?