I am trying to set interface orientation only MPMoviePlayerController
is active. Meanwhile, a movie started to play. In the target of the project, I have checked Portrait
, Landscape Left
and Landscape Right
. Also, in the AppDelegate file, I have implemented supportedInterfaceOrientationsForWindow
method and I tried to check presentedViewController
is a MPMoviePlayerController
. However, I could not implement it correctly.
How can I solve my problem with the correct way ?
What is the best solution changing supported interface orientation when MPMoviePlayerController is active ?
Thank you for your answers
King regards
you need UIInterfaceOrientationMaskAll
only for MPMoviePlayerController
so, while creating the controller use a BOOL
variable to identify interface needed or not .
MPMoviePlayerViewController *playerController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]];
Override the initWithContentURL
method and set AppDelegate BOOL variable to YES
and at viewWillDisappear
set the BOOL to NO
.
In Appdelegate.m
#pragma mark --- Orientation Changes for Movie
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
if (self.OrientationNeeded)
{
return UIInterfaceOrientationMaskAll;
}
return UIInterfaceOrientationMaskPortrait;
}
The flow will be perfect ,first your init method is called and you have setted BOOL variable and then supportedInterfaceOrientationsForWindow
method is called and revert BOOL back when view is out.