Scroll View Delegate
The scroll view’s delegate (adopting the UIScrollViewDelegate protocol) receives lots of messages that can help you track what the scroll view is up to:
-
scrollViewDidScroll: - If you scroll in code without animation, you will receive this message once. If the user drags or flicks, or uses the scroll-to-top feature, or if you scroll in code with animation, you will receive this message repeatedly throughout the scroll, including during the time the scroll view is decelerating after the user’s finger has lifted; there are other delegate messages that tell you, in those cases, when the scroll has really ended.
-
scrollViewDidEndScrollingAnimation: - If you scroll in code with animation, you will receive this message when the animation ends.
-
scrollViewWillBeginDragging:scrollViewWillEndDragging:withVelocity:targetContentOffset:scrollViewDidEndDragging:willDecelerate: If the user scrolls by dragging or flicking, you will receive these messages at the start and end of the user’s finger movement. If the user brings the scroll view to a stop before lifting the finger,
willDecelerateis NO and the scroll is over. If the user lets go of the scroll view while the finger is moving, or if paging is turned on and the user has not paged perfectly already,willDecelerateis YES and we proceed to the delegate messages reporting deceleration.The purpose of
scrollViewWillEndDragging:...is to let you customize the outcome of the content’s deceleration. The third argument is ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access