ios - 游戏中心身份验证 View 未显示 - iOS

标签 ios cocoa-touch game-center viewcontroller presentviewcontroller

我有一个使用 Game Center 的简单 iOS 应用程序。但是最近在将它更新到 iOS 7 时,我注意到身份验证方法不起作用。

其中一个问题是我用来在用户需要登录游戏中心时向其展示 View Controller 的代码,它不再在应用程序中弹出游戏中心登录窗口。

我遇到的另一个问题是我找不到要使用的方法来代替已弃用的“authenticateWithCompletionHandler”。

这是我的代码:

-(void)authenticateLocalUser {

GKLocalPlayer.localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error) {

    if (GKLocalPlayer.localPlayer.authenticated) {
        // Already authenticated
    }

    else if (viewController) {
        [self presentViewController:viewController animated:YES completion:nil];
    }

    else {
        // Problem with authentication, probably bc the user doesn't use Game Center.
    } 
};

if ([GKLocalPlayer localPlayer].authenticated == NO) {

    [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error)  {
        [self callDelegateOnMainThread: @selector(processGameCenterAuth:) withArg:NULL error: error];
    }];
}
}

谢谢你抽出时间,丹。

最佳答案

不管我最后设法弄明白了。至于“authenticateWithCompletionHandler”,我使用了这个:

[[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:viewController animated:YES completion:nil];

关于ios - 游戏中心身份验证 View 未显示 - iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23837763/

相关文章:

ios - 苹果游戏中心 "Delete test data"

ios - 无法访问 AppDelegate

ios - 导入和 iOS Today 扩展不起作用

iphone - 边界和框架 : how do I display part of an UIImage

objective-c - 如何在 iOS 中增加 UIView 的触摸区域

iOS GameCenter 排行榜仅显示我在沙盒模式下的分数

iOS 5 : adding a caption to a camera image

ios - 当尝试快速使用 cocoapods 时出现错误 : bridging header does not exist?

ios - 在 iOS 6 中更改当前 ViewController 上的 backBarButtonItem 颜色

ios - Game Center 可以追踪总玩时间吗?