Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'

Destiny Dawn picture Destiny Dawn · Sep 22, 2012 · Viewed 67.4k times · Source

My app (iPad;iOS 6) is a landscape only application, but when I try using a UIPopoverController to display the photo library it throws this error: Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES. I've tried changing a lot of the code around but I've had no luck.

Answer

Snickers picture Snickers · Sep 25, 2012

In IOS6 you have supported interface orientations in three places:

  1. The .plist (or Target Summary Screen)
  2. Your UIApplicationDelegate
  3. The UIViewController that is being displayed

If you are getting this error it is most likely because the view you are loading in your UIPopover only supports portrait mode. This can be caused by Game Center, iAd, or your own view.

If it is your own view, you can fix it by overriding supportedInterfaceOrientations on your UIViewController:

- (NSUInteger) supportedInterfaceOrientations
{
     //Because your app is only landscape, your view controller for the view in your
     // popover needs to support only landscape
     return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}

If it is not your own view (such as GameCenter on the iPhone), you need to make sure your .plist supports portrait mode. You also need to make sure your UIApplicationDelegate supports views that are displayed in portrait mode. You can do this by editing your .plist and then overriding the supportedInterfaceOrientation on your UIApplicationDelegate:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}