0
votes

I am disabling a UIScrollView when it reaches a particular offset, and would like to re-enable it in a gesture recognizer. The only issue I have is that the scrollview does not get the touch until the the users touch is lifted from the screen.

How can I re-enable the scrollview without lifting a finger?

UIScrollViews category:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}

    UIPanGestureRecognizer *gestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
    gestureRecognizer.delegate = self;
    gestureRecognizer.cancelsTouchesInView = NO;
    gestureRecognizer.delaysTouchesBegan = NO;
    gestureRecognizer.delaysTouchesEnded = NO;
    [self.bodyScrollView addGestureRecognizer:gestureRecognizer];


- (void)handlePanGesture:(UIPanGestureRecognizer *)gesture
{

    if (gesture.state == UIGestureRecognizerStateChanged) {
        if (self.previousAssetsScrollViewOffset.y == -44
            && !self.bodyScrollView.scrollEnabled && !self.composeScrollView.scrollEnabled) {
            self.bodyScrollView.scrollEnabled = YES;
            self.composeScrollView.scrollEnabled = YES;
        }
    }
}
1

1 Answers

0
votes

One problem is that you are not distinguishing between different phases (stages) of the gesture. Thus your handlePanGesture: is called over and over throughout the gesture, and never gives up control over the gesture so that the scroll view can detect that something is happening. Basically, you have "eaten" the entire gesture, so that the scroll view never hears about it.

However, even after you fix that, you may still have a problem, because once your gesture recognizer has recognized, no touches are delivered to other gesture recognizers, including that of the scroll view.