andreamazz / AMScrollingNavbar

Scrollable UINavigationBar that follows the scrolling of a UIScrollView
MIT License
6.05k stars 633 forks source link

Panning gesture #40

Closed vargarobert closed 9 years ago

vargarobert commented 10 years ago

It would be good to have a feature that blocks the pan gesture on the X-axis when a user let's say pans on the Y-axis and the navbar hides. One pan gesture at a time.

zzz6519003 commented 10 years ago

good call!

papauschek commented 10 years ago

I had this problem and fixed it by using the panGesture recognizer of the scrollview, (instead of creating your own, like AMScrollingNavbar does right now)

The solution inside the followScrollView method in UIViewController+ScrollingNavbar.m looks like this:

    UIScrollView* scrollView = (UIScrollView*)self.scrollableView;
    if (![scrollView isKindOfClass:UIScrollView.class]) {
        self.panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
        [self.panGesture setMaximumNumberOfTouches:1];

        [self.panGesture setDelegate:self];
        [self.scrollableView addGestureRecognizer:self.panGesture];
    } else {
        // use existing pan gesture recognizer to avoid nested scrolling issues
        [scrollView.panGestureRecognizer addTarget:self action:@selector(handlePan:)];
    }
andreamazz commented 9 years ago

Closing this issue. Please refer to this https://github.com/andreamazz/AMScrollingNavbar/issues/146