2013-05-27 67 views
1

我一直在寻找过去几天的解决方案,以仅在MPMoviePlayerViewController被触发旋转,没有任何的运气。 我试图启用应用程序的所有旋转,并在每个视图禁用它,但它也没有工作。如何启用旋转仅在视频

没有任何一个有想法?

回答

2
  1. 在目标设定,使所有取向
  2. (可选,UIViewController中默认只有纵向)在所有其它视图控制器,执行以下操作:

    // Deprecated in iOS 6, but still needed for earlier versions of iOS: 
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
        return (interfaceOrientation == UIInterfaceOrientationPortrait); 
    } 
    
    // For iOS 6 and up 
    - (NSUInteger)supportedInterfaceOrientations { 
        return UIInterfaceOrientationMaskPortrait; 
    } 
    
  3. 在应该旋转一个视图控制器,执行以下操作:

    // Deprecated in iOS 6, but still needed for earlier versions of iOS: 
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
        return YES; 
    } 
    
    // For iOS 6 and up 
    - (NSUInteger)supportedInterfaceOrientations { 
        return UIInterfaceOrientationMaskAll; 
    } 
    

这是假定旋转视图控制器不会位于同一个容器视图控制器(如UINavigationControllerUITabBarController)内作为非旋转视图控制器。

+0

我使用的UINavigationController,试图继承它,并花费上面的方法,没有运气... – AndroAid

+0

所以,最终我花费的UINavigationController的和的UITabBarController,实现了上面的方法,它的工作原理!非常感谢!!!!!! – AndroAid

0

创建播放器全屏新ViewController并添加:

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation { 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 

你的代码。

确保你目前的ViewController。 (支持iOS 6以上)

+0

感谢您的答复,但没有奏效。我使用导航控制器的事实是否有任何关系? – AndroAid

+0

确保所有的旋转是在项目 – Segev

+0

的夏日启用,但届时,所有视图将旋转......?我不想意见,从视频除了旋转...... – AndroAid