title: iOS8 - Navigation Controller - Stop Rotation
body: <p>I have a <code>UIViewController</code> that is downstream from a <code>UINavigationController</code>. I need to lock this vc so that it is always in portrait orientation and never rotates. I've tried quite a few approaches, but none of them work. Right now, I'm subclassing <code>UINavigationController</code> like this:</p>
  
  <pre><code>#import "CustomNavigationController.h"
  
  @interface CustomNavigationController ()
  
  @end
  
  @implementation CustomNavigationController
  
  -(NSUInteger)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController {
      NSLog(@"here");
      return navigationController.topViewController.supportedInterfaceOrientations;
  }
  
  - (BOOL)shouldAutorotate {return NO;}
  @end
  </code></pre>
  
  <p>And then in my <code>UIViewController</code>, I have this code:</p>
  
  <pre><code>-(NSUInteger)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController {
      return UIInterfaceOrientationPortrait;
  }
  
  - (UIInterfaceOrientationMask) supportedInterfaceOrientations {return UIInterfaceOrientationMaskPortrait;}
  
  - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {return UIInterfaceOrientationPortrait;}
  
  - (BOOL)shouldAutorotate {return NO;}
  </code></pre>
  
  <p>But this doesn't work. As soon as I rotate the device (simulator), the screen rotates and everything is out of place. Also, the log statement in the nav controller is never generated, so I'm not even getting to this method in the first place.</p>
  
  <p>I have no intention of supporting landscape mode here since the nature of the layout is such that it doesn't make sense.</p>
  
  <p>Can anyone see what I am doing wrong? Thank you.</p>