Reputation: 3575
When I programmatically delete a bunch of cells (I am normally at the bottom of the tableview) there is a move around of all the cells (as the ones being deleted are from the top). How can I stop this moving / jerking / rearranging when I delete them?
Upvotes: 0
Views: 689
Reputation: 533
I think this is the method you're looking for (?) :
[tableView deleteRowsAtIndexPaths: indexPath withRowAnimation: UITableViewRowAnimationNone];
Upvotes: 3
Reputation: 9536
Before calling deleteRowsAtIndexPaths, save the indexPath of the row that is currently visible. Refer to this answer on how to do that.
Once you have the indexPath saved, after your rows are deleted, call this method:
[tableview scrollToRowAtIndexPath:savedIndexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
Upvotes: 1
Reputation: 28688
use reloadData
over adding and removing rows, and it'll all just snap.
Upvotes: 1