I’m having some strange behavior where my MPMoviePlayerViewController isn’t auto-rotating when the orientation changes. However, I recreated the same view hierarchy in a fresh project and when the MPMoviePlayerViewController player was up, it rotated to every orientation. I’ve scoured the project looking for anything that might be setting the orientation explicitly, but there is nothing.
I’ll lay out all the relevant information here and the things that I’ve tried so far.
The view hierarchy currently looks like this:
- Navigation Controller
- “Root” View Controller <- navigation controller’s ‘rootViewController’
- “Feed” View Controller <- Pushed on the navigation stack by the Root VC
- “Preview” View Controller <- Presented as a modal VC from the Feed
- MPMoviePlayerViewController Subclass <- presented by the Feed VC via ‘presentMoviePlayerViewControllerAnimated’
Every class in the view hierarchy responds to shouldAutorotateToInterfaceOrientation with YES only for UIInterfaceOrientationPortrait.
Things I’ve tried:
- Manually sending the
shouldAutorotateToInterfaceOrientationup stack from the “Root” VC up to theMPMoviePlayerViewController - Overriding the
MPMoviePlayerViewControllersubclass’ implementation ofshouldAutorotateToInterfaceOrientationto return YES for both landscape orientations and YES for all orientations. - Setting ‘Supported Device Orientation’ in the project’s summary tab.
- Calling the
presentMoviePlayerViewControllerAnimatedfrom other VCs like the Feed VC
If the movie player properly rotates in a fresh project with same view hierarchy, what could possible be getting in the way here. Any ideas as to where the orientation might be getting stuck?
Solution:
For anyone that might encounter this, the reason the video wasn’t rotating was that I was accidentally adding the RootViewController has the window’s rootViewController, rather than the UINavigationController.
is correct
self.window.rootViewController = rootViewController;
is not
Thank you guys for your help and input along the way.