How to find out if scrollView is about to be scrolled up or down

cocoa-touch, ios, objective-c, scrollview

Solution

Create a declared property to let us know that the tableview is starting to scroll. Let's use a BOOL called `scrollViewJustStartedScrolling`.

In `scrollViewWillBeginDragging` set it to true:

self.scrollViewJustStartedScrolling = YES;

In `scrollViewDidScroll` do something like:

if (self.scrollViewJustStartedScrolling) {
    // check contentOffset and do what you need to do.
    self.scrollViewJustStartedScrolling = NO;
}

Problem

I would like to find out if a scrollView is scrolled up or down. Ideally, I'd like to have only one call if the scrollView is scrolled up or down. I tried this but it will obviously not tell me anything about the direction: ``` -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { NSLog(@"%.2f", scrollView.contentOffset.y); } ``` contentOffset will always be 0 - it doesn't matter whether I scrolled up or down. Now I could simply check in -(void)scrollViewDidScroll: if the offset is positive or negative, but this is called constantly. scrollViewWillBeginDragging has the advantage of being called only once and this is what I need. Is there something like scrollViewDidBeginDragging? I didn't find anything in the docs. Any smart workaround?

Original source