views:

136

answers:

1

I'm doing programmatic scrolling in UITableViews with scrollToRowAtIndexPath, which does not trigger scrollViewDidEndDecelerating. What is a good way to detect when this scrolling has completed?

I ask because in my code:

[tableView1 scrollToRowAtIndexPath:indexPath1 atScrollPosition:UITableViewScrollPositionBottom animated:YES];
[tableView2 scrollToRowAtIndexPath:indexPath2 atScrollPosition:UITableViewScrollPositionMiddle animated:YES];

// Additional methods here

occasionally the later, additional methods fire before this scrolling has completed. I'd like to use something more fool-proof than performSelector: afterDelay:.

+2  A: 

Have you tried scrollViewDidEndScrollingAnimation:? It may have the same issue as your other delegate method, but it's worth a shot. The docs specifically say it's called at the end of setContentOffset:animated: and scrollRectToVisible:animated:, which I have a hunch may be used to implement scrollToRowAtIndexPath:atScrollPosition:.

Edit: it's been confirmed that scrollViewDidEndScrollingAnimation: gets called at the end of scrollToRowAtIndexPath:atScrollPosition:. Thanks Ian!

Tim
Huh, I missed that method in the Docs. I can confirm it does get called at the end of scrollToRowAtIndexPath: (most of the time?! - UIScrollViews seem buggy to me) and is what I was looking for. Thanks.
Ian