I\'m using NSFetchedResultsController
to populate my table. The data in my table is sorted according to the timestamp in the ascending order (latest message at
Are you breaking the data into sections? If you are, check your implementation of controller:didChangeSection:atIndex:forChangeType:
as new section inserts will be animated with the animation types used in that method, not controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:
.
Please try as below.
[CATransaction setDisableActions:YES];
[self.table insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationNone];
[CATransaction setDisableActions:NO]; // reset to original value
I found a way to disable insert/delete cells animation.
[UIView setAnimationsEnabled:NO];
[_tableView beginUpdates];
[_table insertCell...];
[_table removeCell...]
[_table endUpdates];
[UIView setAnimationsEnabled:YES];
It's perfectly doing work.
So I've figured it out.
WWDC 2011 talk "Advanced Table View Techniques" explicitly says that UITableViewRowAnimationNone does not mean no animation (:
As if it made sense.
The animation parameter merely defines how the row is inserted into the space (e.g. slide from the right/left/etc), the transitions to create that space are animated regardless of what user wants.
So yeah, there is no way to insert/delete/refresh individual cells, and reloadData
is the way to go. I love you, Apple.
Now according to many answers on stackoverflow there is also no way to insert content at the top of the table without changing the current view (e.g. seemlessly insert stuff with no changes to what user sees at all). The best one can do is to change the contentOffset
after the new data have arrived.
As of iOS 7.0, you can wrap the code in a performWithoutAnimation:
block, like so:
[UIView performWithoutAnimation:^{
[self.tableView beginUpdates];
[self.tableView deleteRowsAtIndexPaths:rowsToRemove withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
}];