Search code examples
xcoderotationios6

why iPhone 5 doesn't rotate to upsideDown


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?


Solution

  • 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.