整个应用只支持纵向,只有播放视频需要支持所有的方向。该应用程序在iOS < 6.0完全纵向模式下运行良好,现在由于需要支持iOS 6.0的MPMoviePlayerViewController (视频播放)的自动旋转方向,我搜索了很多东西,我找到了下面的解决方案,所以我已经在我的应用程序中应用了这些解决方案。
1)支持plist或target中的所有方向

2)新增如下人像支持定向函数
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (BOOL)shouldAutorotate
{
return NO;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}3)覆盖MPMoviePlayerViewController类,并添加所有合适的定向方法来支持。
4)将下面的方法放在AppDelegate文件中,如果找到MPMoviePlayerViewController的对象,则返回景观。
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { }但是最后,没有成功!-我不能在横向模式下播放视频,整个应用程序只支持肖像。
我不知道为什么它不旋转?我是不是遗漏了什么需要设置的?
发布于 2013-02-23 21:40:08
我最近不得不在我开发的一个应用程序中做相反的事情,我不得不强制视频回放仅在横向模式下显示。我所做的是让我的应用程序支持所有方向,而不是覆盖我的mpMoviePlayerViews shouldAutorotateToInterfaceOrientation方法,只为景观返回YES。
既然你想做相反的事情,那么在你的应用程序中同时允许画像和风景--但将你的常规视图限制在画像上如何?(并因此避免您的问题,以允许您的mpmovieplayerview旋转)我认为应该可以创建一个父(视图)类,您的常规视图可以继承,并在您的父类中只需覆盖shouldAutorotateToInterfaceOrientation以仅支持/返回画像模式的YES。
https://stackoverflow.com/questions/15040973
复制相似问题