title: Rotation in iOS 6 with custom container view controller
body: <p>I have a custom container view controller in my app, and haven't been able to achieve the same rotation behavior in iOS 6 that I had in iOS 5. </p>
  
  <p>The container (call it containerVC) holds two view controllers, one that should stay in portrait (portraitVC) and one that can rotate into landscape (rotatingVC). I switch between them using a segmented control. </p>
  
  <p>If I open the containerVC with portraitVC showing initially, and then rotate the phone to landscape, portraitVC correctly doesn't rotate. BUT if I switch to rotatingVC, rotate into landscape, and then switch to portraitVC while the phone is still held in landscape, portraitVC draws incorrectly draws itself in landscape. </p>
  
  <p>In iOS 5, portraitVC always stays in portrait. </p>
  
  <p>I have this code in the containerVC for switching view controllers:</p>
  
  <pre><code>- (IBAction)segmentChanged:(id)sender {
      UIViewController *toViewController = [self viewControllerForSegmentIndex:self.selectedSegmentIndex];
      [self addChildViewController:toViewController];
  
      UIViewController *fromViewController = self.selectedViewController;
  
      [self transitionFromViewController:self.selectedViewController
                        toViewController:toViewController
                                duration:0
                                 options:0
                              animations:^{}
                              completion:^(BOOL finished) {
                                  self.selectedViewController = toViewController;
                                  [toViewController didMoveToParentViewController:self];
                                  [fromViewController removeFromParentViewController];
                              }];
  }
  </code></pre>
  
  <p>This in the containerVC to handle rotation:</p>
  
  <pre><code>- (NSUInteger)supportedInterfaceOrientations {
      UIInterfaceOrientationMask mask = UIInterfaceOrientationMaskPortrait;
      if ([self.selectedViewController respondsToSelector:@selector(supportedInterfaceOrientations)] ) {
          mask = [self.selectedViewController supportedInterfaceOrientations];
      }
      return mask;
  }
  </code></pre>
  
  <p>This in the portraitVC:</p>
  
  <pre><code>- (NSUInteger)supportedInterfaceOrientations {
      return UIInterfaceOrientationMaskPortrait;
  }
  </code></pre>
  
  <p>And this in the rotatingVC:</p>
  
  <pre><code>- (NSUInteger)supportedInterfaceOrientations {
      return UIInterfaceOrientationMaskAll;
  }
  </code></pre>
  
  <p>When I select the portraitVC after selecting the rotatingVC, none of the rotation methods or callbacks are invoked on the containerVC or portraitVC. The appearance methods are called, and the portraitVC, which holds a tableview, gets UITableViewCells with landscape geometry in the tableview callbacks. </p>
  
  <p>It's not the end of the world if we have to make portraitVC support landscape, but the preference is not to if possible, for consistency with other parts of the app. Seems like there should be a way to get it to work since the built in container VCs work right when you subclass them and override supportedInterfaceOrientations. </p>