2

So, as by the question, I use the following code to set userinterfaceOrientation for the viewcontroller.

- (BOOL) shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

I tried setting UIInterfaceOrientationMaskAll for another viewController.

Prior, I checked all the items for Supported interface orientations in the info-plist. Both the viewControllers returned true(as set in the info-plist) for all the orientations and didn't obey the above code. IT worked even in the absence of the above code. Is there anyway to restrict certain Supported interface orientations for particular classes? I made it working for the pre - iOS6 versions by following this link.

Community
  • 1
  • 1
Ananth
  • 815
  • 9
  • 26

2 Answers2

1

I was able to accomplish this by placing my supported orientation logic in a custom UINavigationController. I then segue to the relevant view controller.

@implementation PortraitNavigationController

- (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}

...

Michael Mangold
  • 1,741
  • 3
  • 18
  • 32
  • Thanks, I created a category and set different options as you did for different viewcontrollers. I referred the link http://stackoverflow.com/a/12526152/1424174 – Ananth Sep 26 '12 at 13:29
-1

I'd say implement your shouldAutorotateToInterfaceOrientation: on every view controller to make it return only YES for those orientations you wish to support.

  • 1
    thanks for your response. But `shouldAutorotateToInterfaceOrientation` is depreciated in iOS6, hence its not called. Thats the problem. I was using it in pre-iOS6 versions – Ananth Sep 26 '12 at 11:47
  • Sorry for my misplaced answer, I was not paying attention enough. For iOS 6, I hope someone else will chime in. – Richard Altenburg - Brainchild Sep 26 '12 at 11:54