Detecting when UIScrollView finished scrolling with delegate methods
suggest changescrollViewDidEndDecelerating tells the delegate that deceleration has finished. If the user stops dragging and the scroll view will not decelerate, the end of the gesture is scrollViewDidEndDragging instead. Implement both, or a drag that stops without coasting never calls stoppedScrolling.
Objective-C:
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
[self stoppedScrolling];
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
if (!decelerate) {
[self stoppedScrolling];
}
}
- (void)stoppedScrolling {
// done, do whatever
}
Swift:
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
if !decelerate {
stoppedScrolling()
}
}
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
stoppedScrolling()
}
func stoppedScrolling() {
// done, do whatever
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents