scrollViewDidScroll not called -- scrollViewDidEndDecelerating is called

1.4k views Asked by At

I have a custom view replacing the keyboard and I'm trying to get it to scroll offscreen when the user scrolls down.

My original scrollViewDelegate methods worked EXCEPT there was a delay between user scrolling and view animation because I was using scrollViewDidEndDecelerating and it took about 1 second for this to be called after the user started scrolling.

  - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    self.isUserScrolling = YES;

    // Save to tell if scrolling up or down
    initialContentOffset = scrollView.contentOffset.y;
    previousContentDelta = 0.f;
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    self.isUserScrolling = NO;

}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {

    self.isUserScrolling = NO;

    // If scrolled down
    CGFloat prevDelta = previousContentDelta;
    CGFloat delta = scrollView.contentOffset.y - initialContentOffset;
    if (delta > 0.f && prevDelta <= 0.f) {

    } else if (delta < 0.f && prevDelta >= 0.f) {
        [self animateKeyBoardSpace:[self rectForKeyboardSpace:NO] curve:UIViewAnimationCurveEaseInOut duration:0.25];
    }
    previousContentDelta = delta;

}

So I am trying to now check for downward scrolling in scrollViewDidScroll and call animateKeyBoardSpace there like so:

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    //    ScrollDirection scrollDirection;
    if (lastContentOffset > scrollView.contentOffset.y) {
        [self animateKeyBoardSpace:[self rectForKeyboardSpace:NO] curve:UIViewAnimationCurveEaseInOut duration:0.25];
    }
    else if (lastContentOffset < scrollView.contentOffset.y) {

    }

    lastContentOffset = scrollView.contentOffset.x;
}

HOWEVER, scrollViewDidScroll isn't even getting called. It's in the same tableViewController, the delegate is set, and the other delegate methods are getting called.

1

There are 1 answers

0
OdieO On BEST ANSWER

I was working in the superclass and I had a stub for scrollViewDidScroll in the subclass from some time ago. This was capturing the delegate call.

I just had to delete the subclass stub.