-scrollViewDidEndDragging:willDecelerate:
is called after you stop dragging, but that's not necessarily when the view stops scrolling. If you want to know when the view stops moving, use -scrollViewDidEndDecelerating:
or -scrollViewDidEndScrollingAnimation:
.
If you only want to know whether the scroll view is currently scrolling, it may be better to ask the scroll view itself instead of trying to keep track of when it starts and when it stops. If the scroll view is scrolling, its either because the user is actively dragging, or because the scroll view is decelerating after a drag. You can easily add a method (in a category) to UIScrollView
that checks both of those conditions:
@interface UIScrollView (Scrolling)
- (BOOL)scrolling;
@end
@implementation UIScrollView (Scrolling)
- (BOOL)scrolling
{
return (self.dragging || self.decelerating);
}
@end