Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPageViewController returns no Gesture Recognizers in iOS 6

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.

like image 662
bjtitus Avatar asked Oct 27 '12 19:10

bjtitus


People also ask

How do I add tap gestures?

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.

What is Pan gesture in IOS?

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.


2 Answers

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.

like image 54
leanne Avatar answered Sep 20 '22 13:09

leanne


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;     } } 
like image 38
dstulic Avatar answered Sep 20 '22 13:09

dstulic