仅横向应用程序中的GameCenter身份验证会引发UIApplicationInvalidInterfaceOrientation [英] GameCenter authentication in landscape-only app throws UIApplicationInvalidInterfaceOrientation

查看:542
本文介绍了仅横向应用程序中的GameCenter身份验证会引发UIApplicationInvalidInterfaceOrientation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Problem: If user is not logged into GameCenter account - GameCenter authentication view is launched in portrait mode (in ios 5 there were a modal dialog) asking to log in. But if I disable Portrait mode in xcode (Project Summary) or in supportedInterfaceOrientationsForWindow: (as my app supposed to run in landscape mode ONLY) I get:

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

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'

如果我启用了Portrait for ipad / iphone(和/或注释出supportedInterfaceOrientationsForWindow :)它没有崩溃,但我不希望启用纵向模式。

If I enable Portrait for ipad/iphone (and/or comment out supportedInterfaceOrientationsForWindow:) it works without crash, but I don't want portrait mode to be enabled.

推荐答案

在撰写此问题并尝试使用代码时,似乎我找到了一个解决方案:
enable all项目摘要中的方向和删除应用程序:supportedInterfaceOrientationsForWindow。

While writing this question and experimenting with code, it seems that I've found a solution: enable all orientations in project summary and remove application:supportedInterfaceOrientationsForWindow.

将此代码添加到ViewController:

Add this code to ViewController:

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

现在无缝运行。

这篇关于仅横向应用程序中的GameCenter身份验证会引发UIApplicationInvalidInterfaceOrientation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆