I have an application that plays videos via a MPMoviePlayerViewController that's presented after a selection action performed on a UITableViewController, which is embedded in a UINavigationController which is embedded in a UITabBarController.
TabBar Controller > Navigation Controller > Table View Controller * MPMoviePlayerViewController
Everything works as expected in iOS5, but upgrading to iOS6 I found that the video did not rotate as expected after being presented. If I selected more supported interface orientations on the target summary page, it causes the whole application to rotate.
The Apple documentation says the following in the UIViewController class reference:
In iOS 6, your app supports the interface orientations defined in your app’s Info.plist file. A view controller can override the supportedInterfaceOrientations method to limit the list of supported orientations. Generally, the system calls this method only on the root view controller of the window or a view controller presented to fill the entire screen; child view controllers use the portion of the window provided for them by their parent view controller and no longer participate in directly in decisions about what rotations are supported. The intersection of the app’s orientation mask and the view controller’s orientation mask is used to determine which orientations a view controller can be rotated into.
But I'm not sure when the child view controllers are actually participating in the rotation decision. Will I need to change the way my Tab Bar Controller responds to shouldAutorotate and supportedInterfaceOrientations when a movie is playing?
The basic answer is that the rotation behavior of all View Controllers is determined by the "top most" view controller, but the MPMoviePlayerViewController determines its own rotation behavior since it acts as a "view controller presented to fill the entire screen".
For example: if I had a single-view application, the auto-rotate methods would be handled on the view controller for the single view. If I embed that view in a tab bar, then the tab bar controller implementation would handle those messages. If I embed the view in a navigation bar inside a tab bar, the tab bar implementation would still be the one handling the messages (it's still the "root view controller" if the other view controllers are embedded inside it).
MPMoviePlayerViewController will respond YES to shouldAutorotate and will support landscape orientations. It is still possible to prevent the movie from rotating (by not having portrait orientations selected on the target summary page), but the settings you choose for your view controller hierarchy will not affect its ability to do so. When the MPMoviePlayerViewController is presented, it is the view controller handling the autorotate messages. When it is not presented, the Tab Bar Controller is in charge.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With