【发布时间】:2012-03-09 01:46:46
【问题描述】:
在 5.1 中是否有任何改变会影响 MPMoviePlayerViewController 在设备方向方面的工作方式?
我今天开始收到来自用户的报告,称视频只能以纵向模式播放。我发现他们使用的是 5.1,我迅速升级了一个设备来重现这种情况。我的代码没有改变并且在 4.x、5.0 和 5.01 中完美运行。
我的应用程序中的所有视图都以纵向模式显示,除非用户点击视频,否则电影播放器应该会占据整个屏幕并以横向模式启动。该应用使用 5.0 SDK 但面向 4.0。这是我用来显示视频的代码:
VideoPlayer *vp = [[VideoPlayer alloc] initWithContentURL:movieURL];
vp.moviePlayer.movieSourceType = src;
vp.moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
vp.moviePlayer.shouldAutoplay = TRUE;
[self presentMoviePlayerViewControllerAnimated:vp];
VideoPlayer 是 MPMoviePlayerViewController 的子类,其中 shouldAutorotateToInterfaceOrientation 被覆盖,如下所示:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIDeviceOrientationLandscapeLeft);
}
整个互联网甚至 Apple 都推荐这种模式。我不明白为什么它不能在 iOS 5.1 下运行,或者为什么没有更多人抱怨这个。
任何帮助将不胜感激。
【问题讨论】:
-
我也有同样的问题,不是电影播放器,而是普通的视图控制器,它以纵向模式显示,但 shoudlAutorotate 方法在纵向模式下返回 NO,如果您有解决方案,请发布它:)
-
我还没有找到解决方案。糟糕的是,我创建了一个新项目并设置了这个基本模式,它运行良好。所以...我认为这与我在生产应用程序中设置的视图层次结构有关。这似乎更像是 5.1 的错误,而不是我的代码,因为它自 3.x 以来一直运行良好。
标签: iphone ios mpmovieplayercontroller mpmovieplayer ios5.1