So we build an iPad App that only supports landscape orientation. This is enforced by setting the Supported interface orientations (iPad)
to Landscape (left/right home button)
in the plist. Also all the UIViewControllers
have the implemented shouldAutorotateToInterfaceOrientation:
as follows:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
This works fine and the App is locked in landscape orientation. Now we have a MPMoviePlayerController
embedded in one of our views. When the user goes fullscreen with this movie, he is able to rotate to portrait. The movieplayer seems to bypass all our landscape settings. That's fine with me, but when the user taps the done
-button when still in portrait orientation all our UIViewControllers
are also in portrait and looking terrible!
The user has to rotate the iPad to landscape himself to make things look good again and will then be unable to rotate back to portrait as expected.
So why are my views rotated to portrait even when all shouldAutorotateToInterfaceOrientation
tell iOS to not rotate to portrait? And how can I make sure the movieplayer does not rotate my views?
If your solution also locks the movieplayer itself in landscape, that's fine with me. I'm happy as long as my views aren't rotated! :)
So why are my views rotated to portrait even when all shouldAutorotateToInterfaceOrientation tell iOS to not rotate to portrait? And how can I make sure the movieplayer does not rotate my views?
If your solution also locks the movieplayer itself in landscape, that's fine with me. As long as my views aren't rotated it's fine with me! :)
I had this exact problem when using this view hierarchy :
+------------------------+ +-------------------+
| | | |
| UINavigationController +->| Some Intermediate |
| | | View Controllers |
+------------------------+ | |
+---------------+---+
|
v
+--------------------------+
| MPMoviePlayerController |
| (embed) |
+--------------------------+
All of the Intermediate view controllers were locked to Landscape orientation so the App could never be in Portrait, except if the MPMoviePlayerController was in full screen (leading to the exact same problem as the OP).
The solution was to lock the UINavigationController to Landscape orientation by creating a subclass that overrides shouldAutorotateToInterfaceOrientation
. This way the MPMoviePlayerController no longer rotates to Portrait orientation. I suspect when entering fullscreen it adds itself to the rootViewController of the mainWindow, which in my case is the UINavigationController (or rather my subclass).
Hope this helps!