title: Supporting multiple orientations on a single view controller
body: <p>I am trying to do a pretty simple thing: support only horizontal orientation in my app, except for 1 stack of view controllers. For simplicity, lets say I have two UIViewControllers. Lets call them maskLandscapeVC and maskAllVC. Each is separately embedded in its own instance of a custom UINavigationController. Here is the code for the navigation controller. </p>
  
  <pre><code>#import "MPTLoginNav.h"
  
  @interface MPTLoginNav ()
  
  @end
  
  @implementation MPTLoginNav
  
  - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  {
      self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
      if (self) {
          // Custom initialization
      }
      return self;
  }
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view.
  }
  
  - (void)didReceiveMemoryWarning
  {
      [super didReceiveMemoryWarning];
      // Dispose of any resources that can be recreated.
  }
  
  #pragma mark
  #pragma Interface Orientaiton Methods
  
  - (NSUInteger)supportedInterfaceOrientations
  {
      if (self.isMaskAllStack)
          return UIInterfaceOrientationMaskAll;
  
      return UIInterfaceOrientationMaskLandscape;
  }
  
  - (BOOL)shouldAutorotate
  {
      return YES;
  }
  
  @end
  </code></pre>
  
  <p>On maskLandscapeVC, this code works fine and only the two horizontal orientations can be used. 
  Users can navigate from maskLandscapeVC to maskAllVC. The following code takes care of that</p>
  
  <pre><code>UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:[NSBundle bundleForClass:[self class]]];
  self.maskAllVC = [storyboard instantiateViewControllerWithIdentifier:@"maskAllVC"];
  [self.navigationController pushViewController:self.maskAllVC animated:YES];
  </code></pre>
  
  <p>At maskAllVC, the code also works great and all four orientations are supported. </p>
  
  <p>Once on maskAllVC, the user switches to VERTICAL orientation. maskLandscapeVC is a delegate of maskAllVC. While in the vertical orientation on maskAllVC, the user presses some button. The button does a call to the delegate (maskLandscapeVC), based on some conditions, maskLandscapeVC decides to dismiss maskAllVC. It uses the following code </p>
  
  <pre><code>[self.maskAllVC.navigationController popViewControllerAnimated:YES];
  [self.maskAllVC.navigationController dismissViewControllerAnimated:YES completion:nil];
  </code></pre>
  
  <p>Now back on maskLandscapeVC, the orientation is still vertical and of course my view is completely messed up because of it. </p>