Can I disable the UIPageViewController's page border gesture recognizers? And keep the swipe one?

Westley picture Westley · Feb 16, 2012 · Viewed 7.1k times · Source

I see that I can remove all of the UIPageViewController gestures, but what if I only want to remove the tap gesture on the edges? And keep the swipe gesture? Is this possible?

Thanks

Answer

rob mayoff picture rob mayoff · Feb 17, 2012

Try looping through pageViewController.gestureRecognizers, disabling any that are tap recognizers.

Objective-C:

for (UIGestureRecognizer *recognizer in pageViewController.gestureRecognizers) {
    if ([recognizer isKindOfClass:[UITapGestureRecognizer class]]) {
        recognizer.enabled = NO;
    }
}

Swift:

for recognizer in pageViewController.gestureRecognizers {
    if recognizer is UITapGestureRecognizer {
        recognizer.isEnabled = false
    }
}