Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grouped UITableView row animation quirks

I've got a grouped UITableView with a couple of rows, and I'm animating a few more rows in and out on the toggle of a button. The problem is that with any of the row animation types I'm using (top & bottom) the animation looks horrible! Here's a screenshot mid-animation:

Example
(source: michaelwaterfall.com)

Is there a reason why it's looking so bad? Or do all grouped table view animations look this shocking!?

I think it only looks so bad when the first or last row in a section is being animated, so I'm just wondering if there's any way to get it looking a bit better!? Otherwise I think I'll just call reloadData and have it all just appear.

Thanks for your help!

Michael

like image 445
Michael Waterfall Avatar asked Jul 28 '09 17:07

Michael Waterfall


1 Answers

If you remove, add and/or move several rows in a UITableView at the same time, then you must enclose all these calls with beginUpdates and endUpdates. Otherwise the result is undetermined.

For example:

[tableView beginUpdates];
[tableView insertRowsAtIndexPaths:newRows 
                    withAnimation:UITableViewRowAnimationTop];
[tableView deleteRowsAtIndexPaths:invalidRows:
                    withAnimation:UITableViewRowAnimationTop];
[tableView endUpdates];
like image 92
PeyloW Avatar answered Nov 11 '22 04:11

PeyloW