Grouped UITableView row animation quirks
animation, iphone, uitableview
Solution
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];
Problem
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: (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