title: Tabbar controller with navigationcontrollers orientation ios 6
body: <p>I'am currently working on an project where we have a tab bar controller with 4 tabs, and where each tab have an navigation controller. On each of these navigation controller there is multiple viewcontrollers pushed on it. </p>
  
  <p>I read a lot of post here and other places, and we have currently done the following:</p>
  
  <p><strong>Subclassed UITabbarcontroller</strong> </p>
  
  <pre><code>- (BOOL)shouldAutorotate
  {
  
      return [[[self.viewControllers objectAtIndex:self.selectedIndex]topViewController] shouldAutorotate];
  
  }
  
  - (NSUInteger) supportedInterfaceOrientations
  {
      return [[[self.viewControllers objectAtIndex:self.selectedIndex]topViewController]supportedInterfaceOrientations];
  }
  
  - (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
      return [[[self.viewControllers objectAtIndex:self.selectedIndex]topViewController] shouldAutorotateToInterfaceOrientation:toInterfaceOrientation];
  }
  </code></pre>
  
  <p>This work fine, if we in each of our viewcontrollers specify the following:</p>
  
  <pre><code>- (NSUInteger) supportedInterfaceOrientations{
      return UIInterfaceOrientationMaskPortrait;
  }
  
  - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
      return YES;
  }
  </code></pre>
  
  <p>This will lock it to Portrait as expected.</p>
  
  <p>But now the real problem occurs!
  If we in our viewcontroller on one of the tabs specify that it should rotate to landscape it works fine, but when we then change tab it is still in landscape, which is not what we want!</p>
  
  <p>So to sum up, have anyone got a solution to how you lock almost all views to a given orientation expect one, and can change tabs where they are in the orientation you specified (here portrait)?</p>
  
  <p>I also read this post <a href="https://stackoverflow.com/questions/12504464/ios-6-uitabbarcontroller-supported-orientation-with-current-uinavigation-control">iOS 6 UITabBarController supported orientation with current UINavigation controller</a>, but as one comment also mentioned "This is almost working for me. The problem is if I am already in landscape when I switch tabs to a portrait only view it is still in landscape. Rotating portrait fixes it and it won't rotate back to landscape, but I still need it be in portrait when it first loads" which almost is the same here..</p>