Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GameCenter authentication in landscape-only app throws UIApplicationInvalidInterfaceOrientation

Tags:

Problem: If user is not logged into GameCenter account - GameCenter authentication view is launched in portrait mode (in ios 5 there were a modal dialog) asking to log in. But if I disable Portrait mode in xcode (Project Summary) or in supportedInterfaceOrientationsForWindow: (as my app supposed to run in landscape mode ONLY) I get:

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'

If I enable Portrait for ipad/iphone (and/or comment out supportedInterfaceOrientationsForWindow:) it works without crash, but I don't want portrait mode to be enabled.

like image 985
Tertium Avatar asked Sep 14 '12 15:09

Tertium


1 Answers

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.

like image 133
Tertium Avatar answered Oct 10 '22 01:10

Tertium