如何在整个应用程序中使用 MPMoviePlayerController 在 iOS 中横向播放视频。我在我的应用程序的许多 viewController 中使用 MPMoviePlayerController,我希望所有 MKMoviePlayerController 仅在横向模式下运行,而不管调用此 ViewController 的父 View Controller 的方向如何。
最佳答案
在您的项目设置中启用横向。
子类 UIViewController 并在您的新子类(例如 MyViewController)中添加这些回调:
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
将所有 View Controller 都设为 MyViewController 类型。
在你想强制横屏覆盖这些方法的 View 中:
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationLandscapeRight;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
关于ios - 将 MKMoviePlayerController 的方向普遍锁定为仅横向模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39776263/