GameCenter authentication in landscape-only app throws UIApplicationInvalidInterfaceOrientation
While writing this question and experimenting with code, it seems that I've found a solution: enable all orientations in project summary and remove application:supportedInterfaceOrientationsForWindow.
Add this code to ViewController:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
Now it works seamlessly.
Add to app delegate:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)w {
return (NSUInteger)[application supportedInterfaceOrientationsForWindow:w] | (1<<UIInterfaceOrientationPortrait);
}
I have found that the problem is coming from the Game Center in my case. When in the simulator I do not have the Game Center initialized yet, it would like to pop up the login view, but in portrait mode. Once it is reaching this point it crashes if I disallowed portrait orientation. Strange bug in the OS as Game Center should take the allowed orientations only to be inline with our intention of landscape user interface.
I do not have the solution yet, but I will post if I find it.