我正在工作的应用程序中,我有一个项目的列表中,我想点击缩略图和视频必须播放,我的要求是只有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];请告诉我怎么弄到它。
发布于 2013-06-17 19:39:47
您必须将代码放在viewwillappear()方法中,这样列表才能以纵向模式显示
发布于 2013-06-17 19:58:42
- (BOOL)shouldAutorotate
{
return NO;
}上面的代码是用mainViewController实现的??
https://stackoverflow.com/questions/17146266
复制相似问题