0

My iOS app is built in portrait format and I want to keep it that way. However there is 1 screen which I would like to be in Landscape ONLY, not portrait but can't figure how to do it.

Is there anything that could be advised?

Much appreciated

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Omar
  • 979
  • 3
  • 16
  • 26

1 Answers1

0

At first you should set up all orientation on Supported Interface Orientation in Xcode project Summary. Then in your appDelegate:

- (NSUInteger) application: (UIApplication*) application supportedInterfaceOrientationsForWindow: (UIWindow*) window
{
    NSUInteger orientations = UIInterfaceOrientationMaskAll;

    if (self.window.rootViewController)
    {
        UIViewController* rootViewController = self.window.rootViewController;
        UIViewController* presented;

        if ([rootViewController isKindOfClass: [UINavigationController class]])
        {
            presented = [[(UINavigationController*) rootViewController viewControllers] lastObject];
        }
        else
        {
            presented = (UIViewController*) rootViewController;
        }

        orientations = [presented supportedInterfaceOrientations];
    }

    return orientations;
}

Then in every UIViewController:

- (NSUInteger) supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

In which you need other orientation you should change from UIInterfaceOrientationMaskPortrait to UIInterfaceOrientationMaskLandscapeLeft or another.

stosha
  • 2,108
  • 2
  • 27
  • 29
  • Thank you - I added that code but it doesn't have seemed to make a difference. I allowed all orientations in Interface in Summary and then added as you said but hasn't worked...anything missing? – Omar Jul 21 '13 at 15:33
  • I created sample project. You can check it https://github.com/SKrotkih/TestRotations – stosha Jul 21 '13 at 17:23