0

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

请让我知道如何获得它。

4

2 回答 2

0

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

于 2013-06-17T11:39:46.710 回答
0
- (BOOL)shouldAutorotate
{
    return NO;
}

在 mainViewController 中实现了上面的代码??

于 2013-06-17T11:58:42.243 回答