I am creating a game on Cocos2d-iPhone, and while I was upgrading to iOS 6, I noticed that Apple had changed the way Game Center was authenticateHandler using authenticateHandler instead of authenticateWithCompletionHandler .
I have added a new authentication method, but now the game ends if the player has not yet entered the Game Center. There is no authentication problem if the user is already logged in.
Here is my code:
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"); } }; }
It seems to crash when trying to present the Control Center viewController, although I use the same code to present the GKTurnBasedMatchmakerViewController without a problem.
Any help would be greatly appreciated.
EDIT: Here is the exception caused by the failure:
Uncaught Exception UIApplicationInvalidInterfaceOrientation: Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES
source share