3

I have Tab Bar Controller app with three UIViewController, all done in storyboard.
Device orientation is set to all, except Upside Down.

For one UIViewController, I have following code:

- (BOOL) shouldAutorotate {
     return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationPortrait;
}

But still I can rotate.
Should not supportedInterfaceOrientations limit that ?

WebOrCode
  • 6,852
  • 9
  • 43
  • 70
  • You need to place these methods inside your root view controller which I presume is your Tab Bar Controller. Additionally you need to return `YES` for `shouldAutorotate`. See [this post](http://stackoverflow.com/questions/12662240/how-to-make-app-fully-working-correctly-for-autorotation-in-ios-6) – sooper Apr 14 '14 at 17:47
  • If I do that, than all ViewController that are inside that TabBarController will not be abel to rotate ? Is this correct ? What I want to do is not to rotate only one ViewController not all. – WebOrCode Apr 14 '14 at 18:36
  • In that case you would put `return self.selectedViewController.shouldAutorotate;` and `self.selectedViewController.supportedInterfaceOrientations;` in the Tab Bar Controller class. This will retrieve the `shouldAutorotate` and `supportedInterfaceOrientations` values from the active view controller and use them for the tab bar controller. – sooper Apr 14 '14 at 18:42

1 Answers1

2

If you are using NavigationController then you should place your code inside the NavigationController class.

Lawliet
  • 3,438
  • 2
  • 17
  • 28