How can I invoke a method upon scrolling-events in a UIScrollView?
-
06-07-2019 - |
Question
I've got an UIScrollView object where I want to implement some effects happening when the user is scrolling. Is there a way to invoke a method on my view controller class every time the user starts a scroll action or is scrolling?
What I need is also the current scrolling position. I am almost sure that there is something useful available. Maybe I could ask 50 times per second for the current scrolling offset or something. Any idea?
Solution
Take a look at the UIScrollViewDelegate
protocol.
You can set your view controller as the delegate for the scroll view and implement some of the methods there, like:
– scrollViewDidScroll:
– scrollViewWillBeginDragging:
– scrollViewDidEndDragging:willDecelerate:
– scrollViewShouldScrollToTop:
– scrollViewDidScrollToTop:
– scrollViewWillBeginDecelerating:
– scrollViewDidEndDecelerating:
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow