ios - 将 MKMoviePlayerController 的方向普遍锁定为仅横向模式

标签 ios objective-c mpmovieplayercontroller landscape

如何在整个应用程序中使用 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/

相关文章:

ios - 如何让MPMoviePlayerController忽略静音开关

ios - 如何在 Swift 中根据上一个 Controller 中选定的单元格值加载数组

iphone - 如何快速从 CoreData 中删除?

jquery - Ajax 调用在 ios 中立即失败,文本状态为 : error and HTTP status 0 on Cordova,

audio - ios声音不再在应用程序中起作用(仅在设备上)

ios - 如何将 mpMoviePlayerController 方向锁定为横向模式?

ios - NSURL - 设置修改路径

ios - 如何从 iOS 应用程序获取设备 ID?

objective-c - 具有固定背景纹理的 NSScrollView

objective-c - 动态附加一个变量属性名