I have a table that when you select an item, it changes some stuff about the object in that cell, and then moves the cell to the bottom, and then reloads the table data.
//update model
...
//move cell to bottom
[tableView beginUpdates];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationBottom];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:lastIndex inSection:0]] withRowAnimation:UITableViewRowAnimationTop];
[tableView endUpdates];
//reload cells
[tableView reloadData];
currently, it works, but doesn’t wait for the animations to finish. How can I wait for the insert and delete animations to finish before reloading the data? or if there is a better way to do it, that would be nice to know as well.
Simple, instead of removing a cell and then immediately adding a new one, you could use UITableView’s
moveRowAtIndexPathwhich will animate the cell from its starting point to its ending point.