gpt4 book ai didi

ios - MPMoviePlayerController 在全屏模式后使 App 的方向不正确

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:32:39 24 4
gpt4 key购买 nike

因此我们构建了一个仅支持横向的 iPad 应用程序。这是通过在 plist 中将 Supported interface orientations (iPad) 设置为 Landscape (left/right home button) 来强制执行的。此外,所有 UIViewControllers 都实现了 shouldAutorotateToInterfaceOrientation:,如下所示:

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

这工作正常,应用程序被锁定在横向。现在我们在其中一个 View 中嵌入了一个 MPMoviePlayerController。当用户全屏观看这部电影时,他可以旋转到纵向。电影播放器​​似乎绕过了我们所有的景观设置。这对我来说很好,但是当用户点击 done 按钮时仍然是纵向的,我们所有的 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 就不再旋转到纵向。我怀疑在进入全屏时它会将自己添加到主窗口的 rootViewController 中,在我的例子中是 UINavigationController(或者更确切地说是我的子类)。

希望这对您有所帮助!

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com