ios - MPMoviePlayerController 在全屏模式后使应用程序处于不正确的方向

标签 ios ipad mpmovieplayercontroller uiinterfaceorientation

因此我们构建了一个仅支持横向的 iPad 应用程序。这是通过在 plist 中将支持的界面方向 (iPad) 设置为横向(左/右主页按钮) 来强制执行的。此外,所有 UIViewControllers 都实现了 shouldAutorotateToInterfaceOrientation:,如下所示:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

这工作正常,应用程序被锁定在横向方向。现在我们的 View 之一中嵌入了一个MPMoviePlayerController。当用户全屏观看这部电影时,他可以旋转到纵向。电影播放器​​似乎绕过了我们所有的景观设置。这对我来说没问题,但是当用户在仍处于纵向方向时点击“完成”按钮时,我们所有的 UIViewControllers 也都是纵向的并且看起来很糟糕!

用户必须旋转 iPad 以横向显示以使事物再次看起来良好,然后将无法按预期旋转回纵向。

那么为什么即使所有 shouldAutorotateToInterfaceOrientation 告诉 iOS 不要旋转为纵向,我的 View 也会旋转为纵向?我怎样才能确保电影播放器​​不会旋转我的 View ?

如果您的解决方案还将电影播放器​​本身锁定在横向模式中,那对我来说没问题。只要我的观点不旋转我就很高兴! :)

最佳答案

So why are my views rotated to portrait even when all shouldAutorotateToInterfaceOrientation tell iOS to not rotate to portrait? And how can I make sure the movieplayer does not rotate my views?

If your solution also locks the movieplayer itself in landscape, that's fine with me. As long as my views aren't rotated it's fine with me! :)

使用此 View 层次结构时我遇到了这个确切的问题:

       +------------------------+  +-------------------+
       |                        |  |                   |
       | UINavigationController +->| Some Intermediate |
       |                        |  | View Controllers  |
       +------------------------+  |                   |
                                   +---------------+---+
                                                   |
                                                   v
                                          +--------------------------+
                                          |  MPMoviePlayerController |
                                          |       (embed)            |
                                          +--------------------------+

所有中间 View Controller 都锁定为横向方向,因此应用程序永远无法处于纵向状态,除非 MPMoviePlayerController 处于全屏状态(导致与 OP 完全相同的问题)。

解决方案是通过创建一个覆盖 shouldAutorotateToInterfaceOrientation 的子类,将 UINavigationController 锁定为横向方向。这样 MPMoviePlayerController 不再旋转到纵向方向。我怀疑当进入全屏时它会将自己添加到 mainWindow 的 rootViewController 中,在我的例子中是 UINavigationController (或者更确切地说是我的子类)。

希望这有帮助!

关于ios - MPMoviePlayerController 在全屏模式后使应用程序处于不正确的方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10091290/

相关文章:

iOS:为应用程序安装过程添加背景图像

objective-c - iPad 上的 UIActionSheet backGroundColor

android - 发布前测试 AdMob

ios - 我如何从 SKScene 移动到 UIViewController

javascript - 如何使用 HTML 和 CSS 创建 Facebook iOS 主屏幕版本?

ios - 在 iPad 上处理旋转到横向模式

iphone - 小视频播放

objective-c - 关于捕获视频截图的问题

ios - MPMoviePlayerController 无法打开

ios - 更改 uitabbar 项目图像的按钮