title: iOS - Force YouTube video in Landscape through UIWebView
body: <p>I have an app which only supports Portrait mode.
  In order to play YouTube video in fullscreen forcing Landscape mode, I tried presenting a modal view controller containing a web view which automatically plays.</p>
  
  <p>For such vc I've implemented:</p>
  
  <pre><code>- (BOOL)shouldAutorotate {
      return YES;
  }
  
  - (NSUInteger)supportedInterfaceOrientations {
      return UIInterfaceOrientationMaskLandscape;
  }
  </code></pre>
  
  <p>Moreover, in the RootViewController (which is a TabBarViewController):</p>
  
  <pre><code>- (BOOL)shouldAutorotate {
      return YES;
  }
  
  - (NSUInteger)supportedInterfaceOrientations {
      NSUInteger orientations = UIInterfaceOrientationMaskPortrait;
  
      if(/*modal view controller with web view is open*/) {
          return UIInterfaceOrientationMaskLandscape;
      }
  
      return orientations;
  }
  </code></pre>
  
  <p>But it does not work, the video rotates and from that point on dismissing the modal vc from landscape mode the entire app remains in landscape.</p>
  
  <p>Any help is really appreciated!</p>
  
  <p>Thanks, DAN</p>