PageViewController with MPMovieViewController

675 Views Asked by At

i'm developing an iOS app for the iPad and used the PageView template. I added some buttons which play some video files. Everything works so far, but the problem is that the touch gestures get called for both views. My view architecture looks like this

I create a MPMovieViewcontroller, set fullscreen mode and add the view to my pageview:

    [[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];

the problem is that if I try to control the volume slider, that gesture turn the pages of the superview of my MPMovieViewController. How can I avoid this?

1

There are 1 best solutions below

0
On

I ran into the same problem and I ended up removing the UIPageViewController gestures from the main view and then readded them when I was done. In my case, I'm showing a toolbar on the screen when someone single taps on the page view controller and then it fades out going back to the page view controller. To allow taps on the toolbar, I did the following:

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

Where self is my extended UIPageViewController and I'm doing this in the method that shows something on the screen. It's going to be a little different in your case, but effectively this should work for you!