Possible Duplicate:
Can you animate a height change on a UITableViewCell when selected?
I have a table view into which where you click on a swich into a cell, many cells of the table view may change their height. It's a little bit complicated to compute which cells will change their size, so I'd like not to call twice the same code.
I have a heightForRowAtIndexPath
method (this is the complicated one).
Is there a way to animate the cell grow or reduce feature without impacting the one that does not change ?
I've tried UIView
Animations, reloadData for sections with animation, ... but I didn't find anything smooth. I've tried to catch each cell that will have to change and call a reloadData with animation on each cell. It's near to work but the cells are updating one after the other. And as I said before, I don't want to do that because I must call twice the heightForRowAtIndexPath method.
What I'd like is something that can animated each cell that has a changing height with somthing like a grow or reduce movement, and not a fade one.
Do you know a way to do that ? One more thing, the content of the cell is changing a little bit when size change (some text added, back color changing, and things like that)
UITableView has a neat trick to animate changes in cell heights: if you send an empty updates block to the table view, it won't insert or delete any cells, but it will still recalculate cell heights for the entire table. So even though this piece of code looks weird, it should do it:
[tableView beginUpdates]; [tableView endUpdates];
If you want to change the contents of the updated cells, too, you must add one or more calls to reloadRowsAtIndexPaths:withRowAnimation:
to the updates block, of course.
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