Ios 当我的应用程序锁定为纵向时,如何将视频视图更改为横向

Ios 当我的应用程序锁定为纵向时,如何将视频视图更改为横向,ios,mpmovieplayercontroller,mpmovieplayer,Ios,Mpmovieplayercontroller,Mpmovieplayer,我正在开发一款iPad/iPhone应用程序,它通过按键显示视频。我有视频工作,但是,我的应用程序被锁定为肖像模式,我想我的视频显示在风景只。这里有一些代码来回答我的问题,如果可能的话,我想用最简单的方法 -(void) view_intro:(UIButton *)introButton { NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Introducti

我正在开发一款iPad/iPhone应用程序,它通过按键显示视频。我有视频工作,但是,我的应用程序被锁定为肖像模式,我想我的视频显示在风景只。这里有一些代码来回答我的问题,如果可能的话,我想用最简单的方法

-(void) view_intro:(UIButton *)introButton {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
               pathForResource:@"Introduction" ofType:@".m4v"]];
moviePlayer =  [[MPMoviePlayerController alloc]
                initWithContentURL:url];

[[NSNotificationCenter defaultCenter] addObserver:self
                selector:@selector(moviePlayBackDidFinish:)
                name:MPMoviePlayerPlaybackDidFinishNotification
                object:moviePlayer];

moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];}

我知道在这种情况下很痛苦。我所做的是旋转整个视图。试试看

    // First rotate the screen:
    [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
    // Then rotate the view and re-align it:
    CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadians(-90));
    landscapeTransform = CGAffineTransformTranslate( landscapeTransform, -90.0, -90.0 );
    [self.view setTransform:landscapeTransform];

基本上,我最后做的是为我的电影播放器创建一个单独的视图/类,这似乎工作得很好。

如果你在侧视图控制器中使用全屏显示视频,那么你可以做一些类似的事情,我做得很好

使viewcontroller仅支持横向模式。(签出横向右侧或左侧)。覆盖下面代码中支持的接口方向签出

-(NSInteger)支持接口方向
{
返回UIInterfaceOrientationMaskLandscape;
}