why iPhone 5 doesn't rotate to upsideDown

15,371

Solution 1

IOS 6 uses default Orientation UIInterfaceOrientationMaskAllfor iPad and UIInterfaceOrientationMaskAllButUpsideDownfor iPhone. If you want your ViewControllers on the iPhone to rotate to ALL orientations including UpsideDown you must add the iOS 6 method:

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

to all view controllers. If you've done this and it is not working then I am betting your using a TabViewController or NavigationController where some of the views are NOT returning this. All ViewControllers must return this for ANY of them to support it.

Alternatively you can add a Category to the UITabViewController or NavigationController class that is your rootViewController and override that method. You do that like so:

@interface UITabBarController (RotationAll)
    -(NSUInteger)supportedInterfaceOrientations;
@end

@implementation UITabBarController (RotationAll)
-(NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}
@end

Also these are the currently recommended approaches now being discussed in Apple Developer Forums with Apple staff saying earlier documentation that discouraged sub classing of UINavigationController is out of date, and as of iOS 6 it is ok to do that.

Solution 2

Thanks to Cliff Ribaudo really help full your answer for UITabbarController based project but in my case i am only using UINavigationController so i have modified your answer for UINavigationController categeory.

@interface UINavigationController (RotationAll)
-(NSUInteger)supportedInterfaceOrientations;
@end   


@implementation UINavigationController (RotationAll)
  -(NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
  }
@end
Share:
15,371

Related videos on Youtube

Jeanette Müller
Author by

Jeanette Müller

Updated on October 30, 2022

Comments

  • Jeanette Müller
    Jeanette Müller over 1 year

    i added the new methods to my code like described at apples iOS 6 Documentations but on the iPhone 5 the App doesn't rotate to upside down. Only the to landscape Ways.

    Here my Code from the rootViewController:

    - (NSUInteger)supportedInterfaceOrientations{
        NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
        return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft |
                UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown);
    }
    - (BOOL)shouldAutorotate{
        NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
        return YES;
    }
    

    i tryed also "UIInterfaceOrientationMaskAll" but no changes. The Strange is, my iPhone 4 with iOS6 does totate o upside down with the same code.

    Any Ideas?

  • ThomasW
    ThomasW about 10 years
    For recent versions of Xcode you don't need the @interface, just having the @implementation works.