I am responding to the scrollViewDidScroll delegate method, and I want to be able to tell if the scrolling happened because the user dragged the table view or if it happened because I programmatically changed the offset.
You don't know whether or not you're programmatically changing the offset?
- nhgrif
If you have a solution I'm open to hearing it. When you programmatically change the offset, the scrollViewDidScroll delegate method is called at several offsets between the one you were at and the one to which you changed it. If you simultaneously have a user invoked change, tracking it gets complicated. I feel like you're suggesting a 'simple' state machine, but I'm struggling with an elegant way of tracking the differences.
- JuJoDi
I think there's a pretty good chance that this is an XY Problem. Why exactly do you need to differentiate between programmatically vs user scrolls?
- nhgrif
You can always disable user interaction on the scrollView, and check whether or not it's enabled in the scrollViewDidScroll. If it's disabled, do the things you need to do, re-enable it, then return.
- nhgrif
Is the delegate method actually called when you programmatically set the content offset?
- rmaddy
1 Answers
4
votes
Use scrollViewWillBeginDragging. This method does not get called when programmatically setting the offset.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more
scrollViewDidScroll
. If it's disabled, do the things you need to do, re-enable it, then return. - nhgrif