繁体   English   中英

用于MPMoviePlayerViewController的UIDeviceOrientation

[英]UIDeviceOrientation for MPMoviePlayerViewController

我正在使用一个应用程序,其中有一个要单击缩略图的项目列表,必须播放视频,我的要求是仅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];

请让我知道如何获得它。

您必须将代码放入viewwillappear()方法中,以便您的列表以纵向模式显示

- (BOOL)shouldAutorotate
{
    return NO;
}

在mainViewController中实现以上代码?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM