Need to perform reloadSections after [self.tableView endUpdates] animation is running

I need to perform

[[self tableView] reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationNone]; 

after

 - (void)controllerDidChangeContent:(NSFetchedResultsController *)controller { // The fetch controller has sent all current change notifications, so tell the table view to process all updates. [self.tableView endUpdates]; } 

animation is in progress.

I want to do it this way because I need to reconfigure some cells in a section when a cell is removed from a section. This is due to the fact that the first and last cell of the section have different backgrounds than the cells between them. One cell has a common background. If I do not reconfigure the cells remaining in the section, this may lead to akward.

Calling reloadSections during controllerDidChangeContent is too soon and fails because the cell can no longer be found.

+6
iphone uitableview
source share
2 answers

If you want to pass more than one argument to a delayed method, wrap the method call in your own method:

 - (void)reloadSections { [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationNone]; } 

Then when you want to restart:

 [self performSelector:@selector(reloadSections) withObject:nil afterDelay:.2]; 
+15
source share

How about this?

 [CATransaction begin]; [CATransaction setCompletionBlock:^{ // animation has finished }]; [tableView beginUpdates]; // do some work [tableView endUpdates]; [CATransaction commit]; 
+2
source share

All Articles