Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 454
Westley Avatar asked Feb 16 '12 22:02

Westley


2 Answers

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     } } 
like image 112
rob mayoff Avatar answered Sep 22 '22 14:09

rob mayoff


If you need to do this in Swift:

    for recognizer in pageViewController.gestureRecognizers as! [UIGestureRecognizer] {         if recognizer is UITapGestureRecognizer {             recognizer.enabled = false         }     } 
like image 40
totiDev Avatar answered Sep 26 '22 14:09

totiDev