UIScrollView Software Scroll End Detection

I do programmatic scrolling in UITableViews with scrollToRowAtIndexPath, which does not fire scrollViewDidEndDecelerating. What is a good way to detect when this scrolling is complete?

I ask because in my code:

[tableView1 scrollToRowAtIndexPath:indexPath1 atScrollPosition:UITableViewScrollPositionBottom animated:YES]; [tableView2 scrollToRowAtIndexPath:indexPath2 atScrollPosition:UITableViewScrollPositionMiddle animated:YES]; // Additional methods here 

sometimes later, additional methods work until this scroll completes. I would like to use something more flawless than performSelector: afterDelay :.

+4
source share
1 answer

Have you tried scrollViewDidEndScrollingAnimation: :? It might have the same problem as your other delegate method, but it's worth it. The docs say they are named at the end of setContentOffset:animated: and scrollRectToVisible:animated: which I have a hunch that you can use to implement scrollToRowAtIndexPath:atScrollPosition:

Edit: it was confirmed that scrollViewDidEndScrollingAnimation: is called at the end of scrollToRowAtIndexPath:atScrollPosition: Thanks to Jan!

+9
source

All Articles