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

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;
}

After spending a lot of time searching a way to avoid subclassing and adding ton of code, here's my one line code solution.

Create a new one UIImagePickerController's category and add

-(BOOL)shouldAutorotate{
    return NO;
}

That's all folks!


There is another case this error message may appear. I was searching for hours until I found the problem. This thread was very helpful after reading it a couple of times.

If your main view controller is rotated to landscape orientation and you invoke a custom sub view controller which should be displayed in portrait orientation this error message can happen when your code looks like this:

- (NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationPortrait;
}

The trap here was xcode's intellisense suggested "UIInterfaceOrientationPortrait" and I didn't care about it. At the first glance this seemed to be correct.

The right mask is named

UIInterfaceOrientationMaskPortrait

Be aware of the small infix "Mask", else your subview will end up with an exception and the mentioned error message above.

The new enums are bit shifted. The old enums return invalid values!

(in UIApplication.h you can see the new declaration: UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait) )

The solution is:

- (BOOL)shouldAutorotate {

    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {

    // ATTENTION! Only return orientation MASK values
    // return UIInterfaceOrientationPortrait;

    return UIInterfaceOrientationMaskPortrait;
} 

In swift use

override func shouldAutorotate() -> Bool {

    return true
}

override func supportedInterfaceOrientations() -> Int {

    return Int(UIInterfaceOrientationMask.Portrait.rawValue)
}