5.1中有什么变化会影响MPMoviePlayerViewController在设备定位方面的工作方式吗?
今天,我开始从用户那里得到报告,说视频只在肖像模式下播放。我发现他们使用的是5.1,我很快升级了一个设备来重新创建这种情况。我的代码没有改变,在4.x、5.0和5.01中运行得很好。
我的应用程序中的所有视图都以纵向模式显示,除非用户单击视频,电影播放器将接管整个屏幕并更多地启动。该应用程序使用5.0SDK,但目标是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);
}这一模式在互联网上得到了广泛的推荐,甚至被苹果公司推荐。我不明白为什么它不能在iOS 5.1下工作,或者为什么更多的人不抱怨这一点。
任何帮助都将不胜感激。
发布于 2012-05-16 09:03:08
我也遇到了同样的问题--我在opengl的子视图上播放电影,(我在景观模式下制作一本交互式电子书,所以需要我的电影-在uiview中)也可以在景观中播放)
我更正了这一点:将打开的glview子类为*viewcontroller,然后将该*viewcontroller链接到窗口
因此,在使用cocos2d时,我现在可以在正确的方向上使用所有的uikit。将所有uikit视图发送给我的子类opengl视图。(同时确保添加我的应用程序委托并检查这个方向也是用plist说明的。)
"#if GAME_AUTOROTATION == kGameAutorotationUIViewController
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
"#else
[director setDeviceOrientation:kCCDeviceOrientationLandscapeRight];
"#endif希望这对某人有帮助:)我在cocos2d非常新,所以花了一段时间才弄清楚我做错了什么。
发布于 2012-03-09 02:09:08
我在iOS 5中也遇到了同样的问题,唯一能让它工作的方法就是子类MPMoviePlayerViewController。
@implementation MovieViewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
} else {
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
}
@end看起来您已经尝试过这样做了,但是这段代码在iOS 5.1的设备上为我工作。不确定模拟器的情况。
发布于 2012-03-13 06:20:03
升级到iOS 5.1之后,我遇到了一系列的定位问题。对我来说,这是因为兄弟级视图控制器在链上的允许方向导致了我正在添加的模态控制器没有允许的方向。
在视图层次结构中是否有将两个子视图添加到视图中的情况?我在applicationDidFinishLaunching中的窗口中添加了两个子视图,在iOS 5.1之前,它们可以有独立的允许的方向。呃,我可以有一个固定的肖像方向,而在顶部旋转。现在,另一个子视图坚持人像定位。
我的解决方案是强制以下非旋转视图:
[self.window insertSubview:self.nonRotatingViewController.view belowSubview:self.rotatingViewController.view];这篇文章帮助我解决了这个问题(并且有一些代码):iOS: Disable Autorotation for a Subview
https://stackoverflow.com/questions/9627857
复制相似问题