【发布时间】:2012-06-27 16:10:24
【问题描述】:
在 iPhone 4/4s 的 iOS5 应用程序中,我有一个 UIViewController,其中添加了一个 MPMoviePlayerController 视图:
[self.view insertSubview:self.fullscreenMoviePlayerController.view atIndex:2];
UIViewController 只支持横向:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation
{
// Return YES for supported orientations.
return interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}
这可以正确地将旋转锁定为仅横向。但是,当我将 MPVideoPlayerController 设置为全屏显示时,这将被忽略,并且视频不再被限制为横向并旋转到手机所在的任何方向。
如何防止 MPMoviePlayerController 的视频全屏旋转到纵向?当手机旋转到纵向时,视频不旋转是至关重要的。
我已经尝试继承 MPVideoPlayerController 并覆盖 shouldAutorotateToInterfaceOrientation: 但这没有效果。
MPMoviePlayerController 只是视图的一部分,因此绝对不能使用 MPMoviePlayerViewCotroller。
【问题讨论】:
-
您需要什么才能始终以横向模式播放视频?是吗
-
是的。无论是否全屏,我都需要视频仅以横向显示。
-
你是在 iPad 还是 iPhone 上工作?
-
为什么不使用 AVPlayer 并将 AVPlayerLayer 添加到显示视图而不是使用 MPVideoPlayerController?
-
@StevenVeltema 如果我在开始时就知道 MPMoviePlayerController 有多么错误,我会这样做并且我肯定会在未来的项目中这样做,但我已经做到了这一点,其他一切都是现在工作正常(经过大量变通后),所以我不愿意放弃这一切,不得不从头开始构建所有 UI。
标签: ios ios5 rotation orientation mpmovieplayercontroller