UIPageViewController returns no Gesture Recognizers in iOS 6

bjtitus picture bjtitus · Oct 27, 2012 · Viewed 15.8k times · Source

I am trying to disable the pan gesture recognizer for a UIPageViewController.

On iOS 5 I can loop through them and disable them.

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

On iOS 6 using UIPageViewControllerTransitionStyleScroll there are no gesture recognizers returned by the Page View Controller.

Clarification

This can be boiled down to:

self.pageViewController.gestureRecognizers = 0 when UIPageViewController's transition style is set to scroll so I can't access the gesture recognizers.

Is there any way I can get around this? I don't think I am doing anything wrong since the curl transition works fine.

Answer

leanne picture leanne · Nov 10, 2012

Found this in UIPageViewController.h:

// Only populated if transition style is 'UIPageViewControllerTransitionStylePageCurl'. @property(nonatomic, readonly) NSArray *gestureRecognizers;

So, not a bug - by design the pageViewController doesn't get gesture recognizers when scroll style is set.