[英]iPhone Movie Rotation For Only Subview
我正在开发一个不允许旋转的应用程序,除非正在播放电影。 我将应用程序旋转得很好,但是当我尝试观看电影时出现了问题。
模拟器被强制旋转,但是电影不旋转。 下面是一个示例:
我也不知道如何旋转电影。 我想只旋转子视图。 我的代码如下:
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:finalURL]];
if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {
// Use the 3.2 style API
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
// Rotate the view for landscape playback
[[moviePlayer view] setBounds:CGRectMake(0, 0, 480, 320)];
[[moviePlayer view] setCenter:CGPointMake(160, 240)];
[[moviePlayer view] setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
// Set frame of movieplayer
[[moviePlayer view] setFrame:CGRectMake(0, 0, 480, 320)];
} else {
// Use the 2.0 style API
moviePlayer.movieControlMode = MPMovieControlModeHidden;
[moviePlayer play];
}
}
编辑:我尝试过[moviePlayer setOrientation UIInterfaceOrientationLandscapeRight];
但是编译器给我一个错误,什么也没发生
您正在使用MPMoviePlayerController
吗?
尝试MPMoviePlayerViewController
。 该类是UIViewController,应该自行处理旋转。
您只需调用方法[moviePlayerViewController moviePlayer];
即可从视图控制器中[moviePlayerViewController moviePlayer];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.