UIPageViewController与MPMovieViewController

时间:2012-05-28 16:24:18

标签: objective-c ios ipad mpmovieplayercontroller pageviews

我正在为iPad开发iOS应用程序并使用PageView模板。我添加了一些播放一些视频文件的按钮。到目前为止一切都有效,但问题是两个视图都会调用触摸手势。 我的视图架构看起来像这样

我创建一个MPMovieViewcontroller,设置全屏模式并将视图添加到我的网页浏览中:

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerFinished:) name:MPMoviePlayerDidExitFullscreenNotification object:nil];
    mediaView = [[MPMoviePlayerViewController alloc] initWithContentURL:mediaURL];
    mediaView.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
    mediaView.moviePlayer.fullscreen = YES;
    mediaView.moviePlayer.view.exclusiveTouch = YES;
    [mediaView shouldAutorotateToInterfaceOrientation:YES];
    [mediaView setWantsFullScreenLayout:YES];
    [mediaView.moviePlayer prepareToPlay];
    [mediaView.moviePlayer play];
    [self.view addSubview:mediaView.view];

问题是,如果我尝试控制音量滑块,那个手势会转动我的MPMovieViewController的超级视图的页面。我怎么能避免这个?

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,我最终从主视图中删除了UIPageViewController手势,然后在完成后重新读取它们。就我而言,当有人单击页面视图控制器时,我会在屏幕上显示一个工具栏,然后它会逐渐退回到页面视图控制器。要允许工具栏上的点按,我执行了以下操作:

// Remove the page controller gestures from the view
for (UIGestureRecognizer *gesture in self.gestureRecognizers) {
    [self.view removeGestureRecognizer:gesture];
}

self是我的扩展UIPageViewController,我在屏幕上显示某些内容的方法中执行此操作。在你的情况下它会有所不同,但实际上这对你有用!