这是一些示例代码,您可以尝试一下,旋转后您必须在 self.view 的中心设置媒体播放器视图,这里是一些示例代码...您必须首先添加 MediaPlayer 框架...。
NSString* moviePath = [[NSBundle mainBundle] pathForResource:@"PATRON_LOGO_3" ofType:@"mp4"];
NSURL* movieURL = [NSURL fileURLWithPath:moviePath];
MPMoviePlayerController *playerCtrl = [[MPMoviePlayerController alloc]initWithContentURL:movieURL];
playerCtrl.scalingMode = MPMovieScalingModeFill;
playerCtrl.controlStyle = MPMovieControlStyleNone;
[playerCtrl.view setCenter:CGPointMake(240, 160)];
[playerCtrl.view setTransform:CGAffineTransformMakeRotation(M_PI/2)];
playerCtrl.view.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:playerCtrl.view];
[playerCtrl play];
我认为它工作正常,这是用于纵向的横向模式,我们必须根据纵向框架设置框架,例如..
playerCtrl.view.frame = CGRectMake(0, 0, 480, 320);
之后,我们必须设置为视图中心。