iPhone - Portrait application but all orientation support for videos
-
24-06-2021 - |
سؤال
Hey looking for some help on this problem.
Currently I'm developing an iPhone application which is locked to portrait orientation throughout, however there are some videos included in the app using the MPMoviePlayer.
I want these videos (which automatically show in fullscreen) to be supported for both portrait and landscape orientations.
Any detailed ideas on how I could go about this? Literally tearing my hair out.
Many thanks!
المحلول
- Remove the limitation from the plist.
- In each of your view controllers, implement
-shouldAutorotateToInterfaceOrientation:
to returnYES
only for supported interface orientations. You must returnYES
for at least one orientation (the normal portrait orientation in your case). Examples abound if you are unclear on how to do this. - As @Till indicated, display your
MPMoviePlayerController
view using a view controller that supports all orientations in its-shouldAutorotateToInterfaceOrientation:
(just returnYES
from the method).
But note that users tend to dislike apps that force an orientation, so make sure you have a very good usability case for why you need to impose this restriction. (The recommendation is you support all orientations except upside down on iPhone, so that the user doesn't try to, say, answer a call upside down.)
نصائح أخرى
Display the MPMoviePlayerController
on the view of a modally presented UIViewController
that allows all possible interface orientations. That way the rest of your app may remain as is (portrait only).