ios:MPMoviePlayerViewController对整个肖像应用程序的所有方向支持

时间:2013-02-23 13:19:47

标签: iphone ios5 ios6 mpmovieplayercontroller uiinterfaceorientation

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

1)支持plist或目标中的所有方向

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 { }

但最后,没有成功! - 我无法在横向模式下播放视频,只有肖像在整个应用中都支持。

我不知道它为什么不旋转?有什么东西我不想设置吗?

1 个答案:

答案 0 :(得分:0)

我最近不得不在我开发的应用程序中做相反的操作,我不得不强制视频播放仅以横向模式显示。我所做的是让我的应用程序支持所有方向,而是覆盖我的mpMoviePlayerViews shouldAutorotateToInterfaceOrientation方法,仅为横向返回YES。

既然你想要做相反的事情,那么如何为你的应用程序同时允许potrait和landscape - 但是将你的常规视图仅限于potrait? (从而避免你的问题允许你的mpmovieplayerview旋转)我认为应该可以创建一个你的常规视图可以继承的父(视图)类,并且在你的父类中只是覆盖shouldAutorotateToInterfaceOrientation只支持/为potrait模式返回YES。

相关问题