首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS 6游戏中心在验证时崩溃

iOS 6游戏中心在验证时崩溃
EN

Stack Overflow用户
提问于 2012-09-27 09:05:26
回答 2查看 4.5K关注 0票数 4

我正在Cocos2d-iPhone中构建一个游戏,当我更新到iOS 6时,我注意到苹果改变了游戏中心认证的方式,使用authenticateHandler而不是authenticateWithCompletionHandler

我添加了新的身份验证方法,但是如果玩家还没有登录到游戏中心,游戏现在就会崩溃。如果用户已经登录,进行身份验证是没有问题的。

下面是我的代码:

代码语言:javascript
复制
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0"))
{
    GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
    localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error)
    {
        if (viewController != nil)
        {
            AppController *appDelegate = (AppController*)[UIApplication sharedApplication].delegate;

            [delegate.viewController presentViewController:viewController animated:YES completion:nil];
        }
        else if (localPlayer.isAuthenticated)
        {
            NSLog(@"Player authenticated");
        }
        else
        {
            NSLog(@"Player authentication failed");
        }
    };
}

在尝试呈现游戏中心viewController时,它似乎崩溃了,即使我使用完全相同的代码来呈现GKTurnBasedMatchmakerViewController没有任何问题。

任何帮助都将不胜感激。

编辑:下面是在崩溃时抛出的异常:

Uncaught Exception UIApplicationInvalidInterfaceOrientation: Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-09-28 19:17:48

在这里你可以找到关于你崩溃的有用信息,我认为这是潜在的原因。https://developer.apple.com/library/ios/#releasenotes/General/RN-iOSSDK-6_0/_index.html

应用程序应该提供委托方法application:supportedIntefaceOrientationsForWindow,并确保肖像是返回的掩码值之一。

我添加了下面的代码来修复这个崩溃。

代码语言:javascript
复制
- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
    return UIInterfaceOrientationMaskAllButUpsideDown;
}
票数 5
EN

Stack Overflow用户

发布于 2012-09-27 18:30:28

有类似的问题,我在viewDidLoad中测试isAuthenticated和authenticateHandler,当在中间加载当前视图时,当试图呈现游戏中心视图时,一直崩溃。我将这个测试移到了viewDidAppear中。

  • (void)viewDidAppear:(BOOL)animated{

它现在工作得很好。

同样对于ios 6,游戏中心将只提示未认证的用户一次,如果他们拒绝登录,它将禁用该应用程序的游戏中心,然后用户将进入游戏中心登录。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12612643

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档