2

我尝试了很多东西,但我仍然无法在所有应用程序中只旋转1个viewControllor。 我想显示(或到轮转)在景观只有一个vc与MPMoviePlayerViewControlleriOS7 viewController和MPMoviePlayerViewController旋转

中的视频Facebook app。该应用程序只是肖像,但视频可以旋转。 播放完视频后,应用程序以纵向模式返回。 我可以调节,但是“完成”录像机按钮在横向模式下点击视图返回。

我该如何解决这个问题?

非常感谢。

+0

请参阅以下网址: http://stackoverflow.com/questions/17680867/ios6-landscape-playing-embedded-youtube-video -of-uiwebview-within-an-only-po – Siddh

+0

查看: http://stackoverflow.com/questions/7407567/reverting-to-portrait-after-done-pressed-on-movie-player 这可能有帮助。 – z22

回答

3
  1. 用于播放视频

  2. 点击项目,然后单击目标创建新的视图控制器。在部署下的信息一般类别使所有的旋转

  3. 现在打开你的根视图控制器,并把下面lines.give什么方向你的应用程序的

代码:

-(BOOL)shouldAutorotate 
{ 
    return TRUE; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) 
    { 
     return UIInterfaceOrientationMaskPortrait; 
    } 
    else 
    { 
     return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; 
    } 
} 

4。现在,如果您使用addsubview方法来表示您的其他ViewController视图,则无需将其他控制器应用于orintation方法。但是,如果有任何VC您使用PresentController方法再添加定位方法到电脑板

+0

嗯,所以,如果我将在HomeVC中有肖像,我可以使用'[self performSegueWithIdentifier:@“myIdentifiew”sender:self];'并设置' - (NSUInteger)supportedInterfaceOrientations返回UIInterfaceOrientationMaskPortrait; }'。但是当我有景观球员时,我必须做些什么?谢谢 – Tenaciousd93

+0

这是没有问题的,但请确保您将来自视频播放vc的位置的方向设置为该vc。 –

+0

SUCCESS !!!它的工作原理:D我在'@interface myPlayerViewController:MPMoviePlayerViewController'中免除每个VC中的'supportedInterfaceOrientations'纵向。如果用户在播放器中按下“完成”按钮,我以前的VC进来了!非常感谢+1和正确答案! – Tenaciousd93

2

创建一个新的UIViewController,您将用它来显示视频。

在viewDidLoad中创建一个MPMoviePlayerController财产

@property (nonatomic, strong) MPMoviePlayerController* moviePlayerController; 

那么,试试这个:

- (void)viewDidLoad 
    { 
     [super viewDidLoad]; 

     _moviePlayerController = [[MPMoviePlayerController alloc] init]; 
     _moviePlayerController.controlStyle = MPMovieControlStyleFullscreen; 

     _moviePlayerController.contentURL = [NSURL URLWithString:@"example.com"]; 

     // Rotating the player to landscape position 
     _moviePlayerController.view.frame = CGRectMake(0.0f, 
              0.0f, 
              [UIScreen mainScreen].bounds.size.height, 
              [UIScreen mainScreen].bounds.size.width); 

     _moviePlayerController.view.transform = CGAffineTransformMakeRotation(M_PI_2); 
     _moviePlayerController.view.center = self.view.center; 

     UIView *playerView = _moviePlayerController.view; 


     [self.view insertSubview:playerView atIndex:0]; 
     [_moviePlayerController prepareToPlay]; 
    } 

希望它能帮助。

+0

谢谢,这可以帮助我,+1!但我必须编辑一些导航栏和状态栏的代码才能获得好的结果。在标记为正确答案之前,我会尝试其他解决方案。谢谢 – Tenaciousd93

相关问题