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:
Every class in the view hierarchy responds to shouldAutorotateToInterfaceOrientation with YES only for UIInterfaceOrientationPortrait.
Things I've tried:
shouldAutorotateToInterfaceOrientation
up stack from the "Root" VC up to the MPMoviePlayerViewController
MPMoviePlayerViewController
subclass' implementation of shouldAutorotateToInterfaceOrientation
to return YES for both landscape orientations and YES for all orientations.presentMoviePlayerViewControllerAnimated
from other VCs like the Feed VCIf 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?
I will suggest you not to use presentMoviePlayerViewControllerAnimated
, rather than add as subview. I think it will fix your problem nicely.
MPMoviePlayerViewController *mpviewController = [[MPMoviePlayerViewController alloc]
initWithContentURL:[NSURL fileURLWithPath:self.filePath]];
[self.view addSubview:mpviewController.view];
[self setWantsFullScreenLayout:YES];
And remove the mpviewController.view
when MPMoviePlayerPlaybackDidFinishNotification
detected. Let me see your success...
I've found that MPMoviePlayerViewController
objects will honor the project's Info.plist settings for supported interface orientations. In a project of mine I was only allowing landscape views in that file so the movie player will not rotate, even when it answered YES
to landscape orientations in shouldAutorotateToInterfaceOrientation:
.
Edit: OK, grasping at straws: Do you implement automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers
in any of your UIViewController
subclasses? If so, and it returns NO
, your subclasses must forward the appropriate methods to any child controllers upon orientation change.
Otherwise is there any way to see your code?
I know this might be a stupid suggestion but make sure that the shouldAutorotateToInterfaceOrientation
method in your MPMoviePlayerViewController
subclass is getting called. Maybe something went wrong there...
Also make sure that you don't have 2 subviews added to the main UIWindow
as specified here:
Q: Why won't my UIViewController rotate with the device?
[...]
- The view controller's UIView property is embedded inside UIWindow but alongside an additional view controller.
I think that might give you some problems too. You can find more information about what could go wrong in the link above.
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