title: IOS Allow portrait orientation only on some views and landscape on others
body: <p>Been trying to figure this one out, some answer in SO looked promising by didn't work. So hope someone can help.</p>
  
  <p>I have an app running on IOS 7 (backwards compatible to IOS 5). Most of the views should be Portrait only, with a handful allowing landscape mode.</p>
  
  <p>But... now matter what I do, I cannot get IOS to prevent views from going into Landscape mode. </p>
  
  <p>The main view is a of type UIViewController. And implements all the methods below (yes tried everything :)</p>
  
  <pre><code>#pragma mark Orientation Methods
  
  - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  {
      // Return YES for supported orientations
      return (interfaceOrientation == UIInterfaceOrientationPortrait);
  }
  
  
  - (BOOL)shouldAutorotate
  {
      return YES;
  }
  
  - (NSUInteger)supportedInterfaceOrientations
  {
      return UIInterfaceOrientationMaskPortrait;
  }
  
  
  
  - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)w {
  
      return (NSUInteger)[application supportedInterfaceOrientationsForWindow:w] | (1&lt;&lt;UIInterfaceOrientationPortrait);
  
  }
  
  - (NSUInteger)application:(UIApplication *)application preferredInterfaceOrientationForPresentation:(UIWindow *)w {
  
      return (NSUInteger)[application supportedInterfaceOrientationsForWindow:w] | (1&lt;&lt;UIInterfaceOrientationPortrait);
  
  }
  </code></pre>
  
  <p>But it still allows the user to change the view into landscape mode. Can anyone help?</p>