pixelfreak pixelfreak - 7 months ago 66
iOS Question

How to detect that animation has ended on UITableView beginUpdates/endUpdates?

I am inserting/deleting table cell using

wrapped in
. I am also using
when adjusting rowHeight. All these operations are animated by default.

How can I detect that animation has ended when using


What about this?

[CATransaction begin];

[CATransaction setCompletionBlock:^{
    // animation has finished

[tableView beginUpdates];
// do some work
[tableView endUpdates];

[CATransaction commit];

This works because the tableView animations use CALayer animations internally. That is, they add the animations to any open CATransaction. If no open CATransaction exists (the normal case), then one is implicitly began, which is ended at the end of the current runloop. But if you begin one yourself, like is done here, then it will use that one.