我有一个使用 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/