I would like to execute some code after a built-in animation is completed.
I have a UITableView with a lot of cells/rows. Sometimes, when I do some operations and then I need to scroll to the top of my tableView. For that I use :
tableView.scrollToRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 0), atScrollPosition: UITableViewScrollPosition.Top, animated: true)
But I need to perform some code once the top is reached, such a simple select and deselect of the 1rst row.
I implemented func scrollViewDidEndScrollingAnimation(scrollView: UIScrollView)
from the UIScrollViewDelegate
. It works fine (more or less, sometimes the animation isn't really smooth and we don't see the select/deselect "animation") except when I am already at the top of the tableView, then scrollViewDidEndScrollingAnimation
isn't called.
So is there a way to execute some code once scrollToRowAtIndexPath:atScrollPosition:animated
has been called?
EDIT:
When I'm talking about doing some operations, I'm talking about moving a row using moveRowAtIndexPath:toIndexPath
from UITableView
.
So when scrolling is needed it's fine, both animations take about the same amount of time. But when no scroll is needed, then the execution of the code I want to do after the animation, starts at the same time than the animation