4

I've implemented scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate in my UIScrollViewDelegate. The method gets called no problem except for when I scroll very quickly. If I do three rapid swipes, for instance, the method will only get called once even though the scroll view will (properly) page three times.

Is there any fix for this? I rely on this method for proper lazy loading behavior and when it doesn't get called it means things will not be loaded in time. If there is no solution for this method, is there another method I could use that would let me know every time the user lifted their finger from the scroll view?

puzzl
  • 833
  • 9
  • 19
  • can you post some code? and you can have a look at this class https://github.com/iVishal/VSScroller.git for lazy loading and reusing views. – Vishal Singh Jun 26 '13 at 04:48

1 Answers1

2

Wow what an old question, but anyways here's the anwser.

scrollView.delegate = self; // or some .m file

then in implementation

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    NSLog(@"Just a usual drag!");
}

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
    // so when dragged quickly, this function will be called instead of didEndDragging
    // now lets trick it to stop the animation of decelerating
    [scrollView setContentOffset:[scrollView contentOffset] animated:NO];
    // and then call the dragging event like nothing even happened
    [scrollView.delegate scrollViewDidEndDragging:scrollView willDecelerate:NO];
}