【发布时间】:2011-06-24 14:23:01
【问题描述】:
我正在开发一个除非正在播放电影,否则不允许旋转的应用。我的应用旋转得很好,但是当我尝试观看电影时出现了问题。
模拟器被强制旋转,但电影没有。下面是一个例子:
我也不知道如何旋转电影。我希望只旋转子视图。我的代码如下:
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];,但编译器给了我一个错误,没有任何反应
【问题讨论】:
-
你在真机上测试过吗?
-
是的,它做同样的事情。
标签: iphone objective-c xcode rotation mpmovieplayercontroller