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.
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.
Adding a Tap Gesture Recognizer in Interface Builder You don't need to switch between the code editor and Interface Builder. Open Main. storyboard and drag a tap gesture recognizer from the Object Library and drop it onto the view we added earlier. The tap gesture recognizer appears in the Document Outline on the left.
A pan gesture occurs any time the user moves one or more fingers around the screen. A screen-edge pan gesture is a specialized pan gesture that originates from the edge of the screen. Use the UIPanGestureRecognizer class for pan gestures and the UIScreenEdgePanGestureRecognizer class for screen-edge pan gestures.
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.
You can always try to disable user interaction on the page view controller's sub view:
for (UIScrollView *view in self.pageViewController.view.subviews) { if ([view isKindOfClass:[UIScrollView class]]) { view.scrollEnabled = NO; } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With