我正在开发一个应用程序,其中我有一个项目列表,我想点击缩略图和视频必须播放,我的要求是只有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];
请让我知道如何获得它 .
2 回答
您将不得不将代码放在viewwillappear()方法中,以便您的列表以纵向模式显示
在mainViewController中实现上面的代码??