首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于MPMoviePlayerViewController的UIDeviceOrientation

用于MPMoviePlayerViewController的UIDeviceOrientation
EN

Stack Overflow用户
提问于 2013-06-17 19:20:37
回答 2查看 147关注 0票数 0

我正在工作的应用程序中,我有一个项目的列表中,我想点击缩略图和视频必须播放,我的要求是只有MPMovieViewController必须旋转剩余的屏幕不得旋转为此我正在使用列表中的以下方法,使它每次肖像。但如果我正在使用它,我就不能旋转MPMoviePlayerViewController。

代码语言:javascript
复制
- (NSUInteger)supportedInterfaceOrientations{

    return (UIInterfaceOrientationMaskPortrait);
}

所以我返回"UIInterfaceOrientationMaskAll“返回后,我能够自动旋转的MPMoviePlayerViewController,但当我回来时,点击完成按钮或在视频完成后,当视频在横向模式,然后我的前一个是旋转,但我不想要的行为,我需要在纵向上的前一个视图,下面是实现的MPMoviePlayerViewContoller代码。

代码语言:javascript
复制
    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];

请告诉我怎么弄到它。

EN

回答 2

Stack Overflow用户

发布于 2013-06-17 19:39:47

您必须将代码放在viewwillappear()方法中,这样列表才能以纵向模式显示

票数 0
EN

Stack Overflow用户

发布于 2013-06-17 19:58:42

代码语言:javascript
复制
- (BOOL)shouldAutorotate
{
    return NO;
}

上面的代码是用mainViewController实现的??

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17146266

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档