title: MPMoviePlayerController re-orientation portrait to landscape and back to portrait (iOS 4.1)
body: <p>Since iOS 3.2 the MPMoviePlayerController class allows to embed a movie in the view hierarchy. 
  Now I'm facing this issue: I create my portrait view by placing an instance of MPMoviePlayerController. When the user touch the "fullscreen" button this view enters in fullscreen mode but the view remains in portrait. When the user rotates the device the fullscreen movie view is not auto-rotated as my app forbids landscape interface orientation.
  So in order to allow auto-rotation of movie player fullscreen view, I changed my view controller shouldAutorotateToInterfaceOrientation: method to return YES for landscape if - and only if - the movie player is in full screen mode. 
  This works perfectly: when the user enters in full screen and then rotates to landscape the player is auto-rotated to landscape and fills the entire screen.</p>
  
  <pre><code>// Override to allow orientations other than the default portrait orientation.
  - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
      // Return YES for supported orientations
      //return (interfaceOrientation == UIInterfaceOrientationPortrait);
      if(UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
          return(YES);
      }
  
      if(UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
          return([movieController isFullscreen]);
      }
  
  return(NO);
  }
  </code></pre>
  
  <p>Now the issue arises when I touch the "Done" button in the full screen view while remaining in landscape. The full screen closes and then what I see is my original view autorotated: but I don't want this auto-rotation.</p>
  
  <p>A partial, but not acceptable solution, is to listen for "MPMoviePlayerDidExitFullscreenNotification" and, if the interface is rotated to landscape, force re-orientation to using the undocumented and private function:</p>
  
  <pre><code>[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait]
  </code></pre>
  
  <p>This works but is not acceptable as usage of this method is forbidden.</p>
  
  <p>I tried to force orientation using <code>[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait]</code> but as I'm in a Tab Bar this doesn't work (the UITabBar remains Landscape-sized).</p>
  
  <p>Thanks for your help</p>