ios 8 - MPMoviePlayerController视频无法相应旋转

时间:2014-10-28 14:15:09

标签: ios video rotation

在我的应用程序中,我正在尝试使用MPMoviePlayerController在横向和纵向模式下播放视频。我写了一段播放视频和播放的代码处理它的轮换。我目前的代码在ios 7中完全正常工作,但在ios 8中,问题是在将ipad的旋转更改为横向时,视频仍然以纵向模式运行。任何人都可以建议我一个方法,以便我可以摆脱这个问题。

我现在的代码是:

NSURL *videoURL = [NSURL fileURLWithPath:urlFromPrevious];

moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
moviePlayerController.scalingMode = MPMovieScalingModeAspectFit;
moviePlayerController.fullscreen=YES;

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willExitFullScreen:) name:MPMoviePlayerWillExitFullscreenNotification object:moviePlayerController];

[[moviePlayerController view] setFrame:CGRectMake(x_axe_forImage, y_axe_forImage, width_forImage, height_forImage+44)];

[[self view] addSubview:[moviePlayerController view]];

[moviePlayerController play];

1 个答案:

答案 0 :(得分:0)

看看How to use MPMoviePlayerController。您必须使用正确的UIViewController选择器呈现该视图控制器:'presentMoviePlayerViewControllerAnimated'