私はCocos2d-iPhoneでゲームを構築していますが、iOS 6にアップデートしているときに、AppleがauthenticateHandler
代わりにを使用してGameCenter認証の方法を変更したことに気付きました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");
}
};
}
まったく同じコードを使用して問題なく表示しようとしても、GameCenterviewControllerを表示しようとするとクラッシュしているようGKTurnBasedMatchmakerViewController
です。
どんな助けでも大歓迎です。
編集:クラッシュ時にスローされる例外は次のとおりです。
Uncaught Exception UIApplicationInvalidInterfaceOrientation: Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES