title: iOS 11 Force UIViewController to portrait mode doesn't work
body: <p>Based on <a href="https://discussions.apple.com/thread/4997560?start=0&amp;tstart=0" rel="nofollow noreferrer">the discussing</a> on Apple's forum, this method works great on iOS &lt; 11 device (But > iOS 6)</p>
  
  <blockquote>
    <p>This will prevent any rotation.</p>
  </blockquote>
  
  <pre><code>- (BOOL)shouldAutorotate
  {
      return NO;
  }
  </code></pre>
  
  <blockquote>
    <p>This will only rotate to portrait (right-side-up or up-side-down).</p>
  </blockquote>
  
  <pre><code>- (NSUInteger)supportedInterfaceOrientations
  {
      return UIInterfaceOrientationMaskPortrait + UIInterfaceOrientationMaskPortraitUpsideDown;
  }
  </code></pre>
  
  <p>However, it's not working on iOS 11 Beta 9;</p>
  
  <p>If you have an app that allow all orientations but want to set MainViewController to Portrait only by using this. </p>
  
  <p>If you hold your device landscape and start the app, after a launching screen, the statusBar will be on the top of screen (when landscape) and your view still portrait.</p>
  
  <p>If you use method to switch rootViewController <a href="https://stackoverflow.com/a/26681430/4196468">like this answer</a>, you will end up a landscape rendered view that force showing in portrait.</p>
  
  <p>Some example graph like this one:</p>
  
  <p><a href="https://i.stack.imgur.com/GJDP0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GJDP0.jpg" alt="enter image description here"></a></p>
  
  <p>The Gear Icon is at correct location but that was from a library. Everything else looks like landscape.</p>
  
  <p>Thanks</p>