Cocoa-Touch:如何允许 MPMoviePlayerController 但不允许其他视图自动旋转?

发布于 2024-10-04 06:06:20 字数 878 浏览 2 评论 0原文

我有这个 iOS 3.2 应用程序 (iPad),其中包含大量内容和一些视频。

所有视图都是纵向的,除了纵向内嵌的视频,具有全屏选项,我想让用户在全屏时自动旋转视频。

shouldAutorotateForInterfaceOrientation: 中,我的应用程序通常拒绝自动旋转。

如何让 MPMoviePlayerController 的视图自动旋转,而不是我的应用程序中的任何其他视图?

我想到的一些想法:

  1. in shouldAutorotateForInterfaceOrientation::
    return isFullscreenMovieActive;
    这将使应用程序允许在电影处于全屏模式时旋转。除了一个大问题之外,这一切都很完美,一旦用户退出全屏模式,我就无法强制应用程序返回纵向模式。 (即用户启动应用程序,找到电影播放器​​,播放它,进入全屏模式,旋转设备,按完成,现在他的应用程序处于横向模式)
    是否有可接受的方法强制旋转到 UIInterfaceOrientation

  2. Apple 实际上建议从 MPMoviePlayerController 的视图方法中获取它的视图。当设备旋转时,实际发生的情况是应用的 UIWindow 会应用一个 CGAffineTransform。因此,我可以对 MPMoviePlayerController 的视图执行此操作,但是当进入全屏模式时,视图会发生变化,而不是视图属性中的视图。
    那么有没有任何可接受的方法来获取 MPMoviePlayerController 的全屏视图?

或者这个任务有更好的解决方案吗?

I have this iOS 3.2 app (iPad) which has lots of content, and a few videos.

All the views are in portrait, except for the videos which are portrait inline, with a fullscreen option, and I'd like to let the user autorotate the video while fullscreen.

In shouldAutorotateForInterfaceOrientation: my app generally refuses autorotation.

How can I let MPMoviePlayerController's view autorotate, but not any other views in my app?

A few ideas I've thought of:

  1. in shouldAutorotateForInterfaceOrientation::
    return isFullscreenMovieActive;
    which would make the app allow rotation while a movie is in fullscreen mode. This works perfectly except for one huge issue, I cannot force the app back into portrait mode once the user exits fullscreen mode. (i.e. user starts app, finds a movie player, plays it, goes to fullscreen mode, rotates the device, presses done, now he has the app in landscape mode)
    Is there an acceptable way to force rotating to a UIInterfaceOrientation?

  2. Apple actually recommends grabbing MPMoviePlayerController's view from it's view method. When the device rotates, what actually happens is that the app's UIWindow gets a CGAffineTransform applied to it. So I could do this to MPMoviePlayerController's view, but when entering fullscreen mode the view changes and is not the one in the view property.
    So is there any acceptable way to get MPMoviePlayerController's fullscreen view?

Or is there a better solution for this task?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

简美 2024-10-11 06:06:20

每个视图控制器都可以通过 shouldAutorotateForInterfaceOrientation: 返回它支持的方向。您的应用的控制器应该只针对纵向旋转返回 true,MPMoviePlayerController 除外。当您的应用显示视频时,使用 presentModalViewController:animated: (或 presentViewController:animated:completion:)在其他视图控制器上呈现 MPMoviePlayerController iOS 5)。视频播放完毕后,关闭特殊的电影播放器​​控制器,您的其他控制器应仍处于纵向模式。

Each view controller can return the orientations it supports with shouldAutorotateForInterfaceOrientation:. Your app's controllers should only return true for the portrait rotations, except for the MPMoviePlayerController. When your app displays the video, present the MPMoviePlayerController over your other view controller with presentModalViewController:animated: (or presentViewController:animated:completion: in iOS 5). Once the video is done, dismiss the special movie player controller, and your other controller should still be in portrait mode.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文