iOS   发布时间:2022-03-31  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了GKLocalPlayer在iOS6上使用模态转换错误进行Auth崩溃大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我的应用程序记录了它是否已成功通过Game Center进行身份验证.当它开始新游戏或用户查看分数列表时,如果本地播放器未成功通过身份验证,并且该应用程序当时未尝试对用户进行身份验证,则会再次尝试.

(为什么?如果您从无网络区域移动到网络区域.)

不幸的是,在iOS6 / XCode 4.5下,它开始崩溃了.或者至少在某些有限的情况下似乎:用户无法使用@L_801_3@的密码和/或不存在的帐户登录.成功登录后,一切顺利.

登录失败之后,当我去做一些导致进行reauth检查的事情时,我得到了这个:

然后这实际上崩溃了:

这是麻烦的代码

-(void)authenticateLocalUser {

    if (!self.checkingLocalPlayer) {
        self.checkingLocalPlayer = YES;
        GKLocalPlayer *thisPlayer = [GKLocalPlayer localPlayer];

        if (!thisPlayer.authenticated) {

            [[GKLocalPlayer localPlayer]
             authenticateWithCompletionHandler:^(NSError *error)
             {
                 [self finishGameCenterAuthWithError:error];
             }
             ];
        }
    }
}

知道我在这里做错了吗?

解决方法

Ggrrrhhh同样的问题,想想我发现它… ios6已弃用authenticateWithCompletionHandler看到链接,建议你使用AuthenticateHandler.

@L_489_11@

这似乎有效……

GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
[localPlayer setAuthenticateHandler:(^(UIViewController* viewcontroller,NSError *error) {

//[localPlayer authenticateWithCompletionHandler:^(NSError *error) { OLD CODE!
    if (localPlayer.isAuthenticated)
    {
        //do some stuff
    }
    else {

        UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithtitle:@"NOT AUTHORISED"
                                  message:@"YOUR'RE NOT LOGGED INTO GC."
                                  delegate:self
                                  cancelButtontitle:@"OK"
                                  otherButtontitles:nil];
        [alertView show];

    }
})];

大佬总结

以上是大佬教程为你收集整理的GKLocalPlayer在iOS6上使用模态转换错误进行Auth崩溃全部内容,希望文章能够帮你解决GKLocalPlayer在iOS6上使用模态转换错误进行Auth崩溃所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。