Search code examples
cocoa-touchuislideruipageviewcontroller

UISlider inside UIPageViewController


I have a PageViewController which is initialized like this:

self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll
                          navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];

On one of the pages, there's a UISlider.

My problem is that when I have transitionstyle set to UIPageViewControllerTransitionStyleScroll, it takes 150-200 ms before beginTrackingWithTouch is invoked on the slider. This behavior is not seen when I use UIPageViewControllerTransitionStylePageCurl, where the UISlider is selected instantly.

This means that unless the user waits a bit before dragging the slider (a video progress), the page will turn instead, which is far from ideal.

The Page curl animation does not meet the demands of the app, so any explanation or workaround is appreciated.


Solution

  • Since with UIPageViewControllerTransitionStyleScroll gesture recognizers isn't available, you can use this:

    for (UIView *view in pageViewController.view.subviews) {
        if ([view isKindOfClass:[UIScrollView class]]) {
            UIScrollView *scrollView = (UIScrollView *)view;
            scrollView.delaysContentTouches = NO;
        }
    }