How can I cause action to be taken upon completion of a UITableview's animation?
I'm attempting to shrink a UITableview cell and remove a subview of the cell that's not visible after the shrinkage. To shrink the cell, I'm calling [tableview beginUpdates] and [tableview endUpdates], and changing the height of the cell as returned by theheightForRowAtIndexPath datasource method of the UITableview.
The challenge is, i need the tableview to complete shrinking so the subview is out of sight before I can remove the subview. if I put the code to remove the subview from the cell right after (or before or between) the to call [tableview endUpdates] then the subview is removed too soon (it doesn't wait for the animation) and it looks funny.
My thought is i'd like to be able to setup a callback that runs upon completion of the animation, and remove the subView in the callback
What about this?
[CATransaction begin];
[CATransaction setCompletionBlock:^{
// animation has finished
}];
[tableView beginUpdates];
// shrink the cells
[tableView endUpdates];
[CATransaction commit];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With