How to detect when a UIScrollView has finished scrolling

advertisements

UIScrollViewDelegate has got two delegate methods scrollViewDidScroll: and scrollViewDidEndScrollingAnimation: but neither of these tell you when scrolling has completed. scrollViewDidScroll only notifies you that the scroll view did scroll not that it has finished scrolling.

The other method scrollViewDidEndScrollingAnimation only seems to fire if you programmatically move the scroll view not if the user scrolls.

Does anyone know of scheme to detect when a scroll view has completed scrolling?


The methods you're looking for are scrollViewDidEndDragging:willDecelerate: and scrollViewDidEndDecelerating:. The first one is always called after the user lifts their finger. If they scrolled fast enough to result in deceleration, willDecelerate will be YES and the second method will be called after deceleration completes.

(From the UIScrollViewDelegate docs.)