iOS 6 Game Center 在身份验证时崩溃 [英] iOS 6 Game Center Crash on Authentication
问题描述
我正在 Cocos2d-iPhone 中构建游戏,当我更新到 iOS 6 时,我注意到 Apple 改变了 Game Center 身份验证的方式,使用 authenticateHandler
而不是 authenticateWithCompletionHandler代码>.
I am building a game in Cocos2d-iPhone, and while I was updating to iOS 6, I noticed that Apple changed the way Game Center authentication is done, using authenticateHandler
instead of authenticateWithCompletionHandler
.
我添加了新的身份验证方法,但如果玩家尚未登录 Game Center,游戏现在会崩溃.如果用户已经登录,则验证没有问题.
I added the new authentication method, but the game now crashes if a player is not already logged in to Game Center. There is no problem authenticating if a user is already logged in.
这是我的代码:
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
没有任何问题.
It seems like it's crashing when trying to present the Game Center viewController, even though I use the exact same code to present the GKTurnBasedMatchmakerViewController
with no issues.
任何帮助将不胜感激.
这是崩溃时抛出的异常:
Here is the exception getting thrown on crash:
未捕获的异常 UIApplicationInvalidInterfaceOrientation:支持的方向与应用程序没有共同的方向,并且 shouldAutorotate 正在返回 YES
推荐答案
在这里您可以找到有关崩溃的有用信息,我认为这是根本原因.https://developer.apple.com/library/ios/#releasenotes/General/RN-iOSSDK-6_0/_index.html
Here you can find useful information about your crash, I think it is the underlying reason. https://developer.apple.com/library/ios/#releasenotes/General/RN-iOSSDK-6_0/_index.html
应用应提供委托方法 application:supportedIntefaceOrientationsForWindow 并确保肖像是返回的掩码值之一.
Apps should provide the delegate method application:supportedIntefaceOrientationsForWindow and ensure that portrait is one of the returned mask values.
我添加了下面的代码来修复这个崩溃.
I added below code to fix this crash.
- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
这篇关于iOS 6 Game Center 在身份验证时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!