Detecting when UIScrollView finished scrolling with delegate methods

suggest change

scrollViewDidEndDecelerating 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
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents