您只需UIInterfaceOrientationMaskAll 要这样做,MPMoviePlayerController在创建控制器时使用BOOL变量来识别是否需要接口。
MPMoviePlayerViewController *playerController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]];
覆盖该initWithContentURL方法并将 AppDelegate BOOL 变量设置为YES并将viewWillDisappearBOOL 设置为NO。
在 Appdelegate.m 中
#pragma mark --- Orientation Changes for Movie
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
if (self.OrientationNeeded)
{
return UIInterfaceOrientationMaskAll;
}
return UIInterfaceOrientationMaskPortrait;
}
流程将是完美的,首先调用您的 init 方法并设置 BOOL 变量,然后supportedInterfaceOrientationsForWindow调用方法并在视图消失时恢复 BOOL。