Animate Table Row Deletion
It’s simple, but there are a lot of small things that can go wrong.
[tableView beginUpdates]; [self updateModels]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; [tableView endUpdates];
updateModels to update the table’s data source. The data needs to be valid after the animation. It should not contain the object associated with the row that will be deleted.
Careful, if the model is invalid, your app will crash. If
updateModels is outside the “updates” block, your app will crash.
If your table view has section headers, good luck. I played around with it. It doesn’t work well. (Tip: the header needs to be removed from the table’s data source after