我正在开发一个应用程序,其中我有一个项目列表,我想在其中单击缩略图并且必须播放视频,我的要求是只有 MPMovieViewController 必须旋转剩余的屏幕不能为此旋转我在列表中使用以下方法每次都画肖像。但如果我使用它,我将无法旋转 MPMoviePlayerViewController。
- (NSUInteger)supportedInterfaceOrientations{
return (UIInterfaceOrientationMaskPortrait);
}
所以我返回后返回“UIInterfaceOrientationMaskAll”,我能够自动旋转 MPMoviePlayerViewController 但是当我回来点击完成按钮或视频处于横向模式时视频完成后,我的前一个正在旋转,但我不希望这种行为我需要前一个纵向查看,下面是实现 MPMoviePlayerViewContoller 的代码。
NSString *filepath = [[NSBundle mainBundle] pathForResource:[exeDict objectForKey:@"longVideoName"] ofType:@"mp4"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayerController.moviePlayer];
[moviePlayerController.view setFrame:CGRectMake(0, 0, 320, 480)];
moviePlayerController.moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
moviePlayerController.view.userInteractionEnabled =YES;
[moviePlayerController shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationMaskAll];
// AppDelegate* myDelegate = (((AppDelegate*) [UIApplication sharedApplication].delegate));
// [myDelegate.window addSubview:moviePlayerController.view];
MainViewController* mainViewController = (MainViewController*)self.mainViewDelegate;
[mainViewController presentMoviePlayerViewControllerAnimated:moviePlayerController];
[moviePlayerController.moviePlayer play];
请让我知道如何获得它。