0

我正在尝试仅设置界面方向MPMoviePlayerController处于活动状态。与此同时,一部电影开始播放。在项目的目标中,我检查了Portrait,Landscape LeftLandscape Right. 此外,在 AppDelegate 文件中,我已经实现了supportedInterfaceOrientationsForWindow方法并尝试检查presentedViewController是否为MPMoviePlayerController. 但是,我无法正确实现它。如何以正确的方式解决我的问题?当 MPMoviePlayerController 处于活动状态时,更改支持的界面方向的最佳解决方案是什么?

谢谢您的回答

国王问候

4

1 回答 1

1

您只需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。

于 2015-07-19T04:51:47.187 回答