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?
Create a declared property to let us know that the tableview is starting to scroll. Let’s use a BOOL called
scrollViewJustStartedScrolling.In
scrollViewWillBeginDraggingset it to true:In
scrollViewDidScrolldo something like: