ios – authPlayerWithCompletionHandler不推荐使用,所以如何使用authenticateHandler

ios – authPlayerWithCompletionHandler不推荐使用,所以如何使用authenticateHandler,第1张

概述在标题中有很多问题,authPlayerWithCompletionHandler已被弃用,那么如何使用authenticateHandler? setAuthenticateHandler是iOS 6中的新增功能,authenticateWithCompletionHandler仍然必须在iOS 5及更低版本中使用. 此外,为presentViewController提供完成处理程序:anima 在标题中有很多问题,authPlayerWithCompletionHandler已被弃用,那么如何使用authenticateHandler?解决方法 setAuthenticateHandler是iOS 6中的新增功能,authenticateWithCompletionHandler仍然必须在iOS 5及更低版本中使用.

此外,为presentVIEwController提供完成处理程序:animated:completion:完全不需要,因为完成处理程序是在游戏中心视图显示之后调用的,而不是在完成后才调用.

这是我的解决方案:

注意 – 仅在iOS 4.3,iOS 5.1,iOS 6.0模拟器上测试 – 不在实际设备上.

注意 – 这假定您检查了GameCenter API是否可用.

- (voID)checkLocalPlayer{    GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];    if (localPlayer.isAuthenticated)    {        /* Perform additional tasks for the authenticated player here */    }    else    {        /* Perform additional tasks for the non-authenticated player here */    }}#define SYstem_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] \compare:v options:NSNumericSearch] == NSOrderedAscending)- (voID)authenticateLocalPlayer{        GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];        if (SYstem_VERSION_LESS_THAN(@"6.0"))        {            // ios 5.x and below            [localPlayer authenticateWithCompletionHandler:^(NSError *error)             {                 [self checkLocalPlayer];             }];        }        else        {            // ios 6.0 and above            [localPlayer setAuthenticateHandler:(^(UIVIEwController* vIEwcontroller,NSError *error) {                if (!error && vIEwcontroller)                {                    [[AppDelegate sharedDelegate].vIEwController                    presentVIEwController:vIEwcontroller animated:YES completion:nil];                }                else                {                    [self checkLocalPlayer];                }            })];        }    }}
总结

以上是内存溢出为你收集整理的ios – authPlayerWithCompletionHandler不推荐使用,所以如何使用authenticateHandler全部内容,希望文章能够帮你解决ios – authPlayerWithCompletionHandler不推荐使用,所以如何使用authenticateHandler所遇到的程序开发问题。

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

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1095688.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存