Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS UITableview how to take action after table animations complete

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

like image 471
kris Avatar asked Jun 08 '11 05:06

kris


1 Answers

What about this?

[CATransaction begin];

[CATransaction setCompletionBlock:^{
    // animation has finished
}];

[tableView beginUpdates];
// shrink the cells
[tableView endUpdates];

[CATransaction commit];
like image 163
Rudolf Adamkovič Avatar answered Sep 20 '22 18:09

Rudolf Adamkovič