我正在 Cocos2d-iPhone 中构建游戏,当我更新到 iOS 6 时,我注意到 Apple 改变了 Game Center 身份验证的方式,使用authenticateHandler
而不是authenticateWithCompletionHandler
.
我添加了新的身份验证方法,但如果玩家尚未登录 Game Center,游戏现在会崩溃。如果用户已经登录,则验证没有问题。
这是我的代码:
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");
}
};
}
尝试呈现 Game Center viewController 时似乎崩溃了,即使我使用完全相同的代码来呈现GKTurnBasedMatchmakerViewController
没有问题。
任何帮助将非常感激。
编辑:这是崩溃时抛出的异常:
Uncaught Exception UIApplicationInvalidInterfaceOrientation: Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES