通常只将MKMoviePlayerController的方向锁定为横向模式

时间:2016-09-29 17:11:19

标签: ios objective-c mpmovieplayercontroller landscape

如何使用MPMoviePlayerController在整个应用程序中以横向方式播放iOS中的视频。我在我的应用程序的许多viewControllers中使用MPMoviePlayerController,我希望所有MKMoviePlayerController仅在横向模式下运行,而不管调用此ViewController的父视图控制器的方向如何。

1 个答案:

答案 0 :(得分:1)

在项目设置中启用横向显示。

子类UIViewController和你的新子类(例如MyViewController)添加这些回调:

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

制作MyViewController类型的所有视图控制器。

在视图中,您要强制使用以下方法覆盖这些方法:

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeRight;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}