[self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 1)] withRowAnimation:UITableViewRowAnimationLeft]; [self.tableView reloadRowsAtIndexPaths:@[ [NSIndexPath indexPathForItem:1 inSection:1]] withRowAnimation:UITableViewRowAnimationRight];
Dans le code ci-dessus, comment faire exécuter la deuxième ligne après que l'animation de la première ligne est terminée?
J'ai essayé ça …
[self.tableView beginUpdates]; [self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 1)] withRowAnimation:UITableViewRowAnimationLeft]; { [self.tableView beginUpdates]; [self.tableView reloadRowsAtIndexPaths:@[ [NSIndexPath indexPathForItem:1 inSection:1]] withRowAnimation:UITableViewRowAnimationRight]; [self.tableView endUpdates]; } [self.tableView endUpdates];
et ça…
[self.tableView beginUpdates]; { [self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 1)] withRowAnimation:UITableViewRowAnimationLeft]; } [self.tableView endUpdates]; [self.tableView beginUpdates]; { [self.tableView reloadRowsAtIndexPaths:@[ [NSIndexPath indexPathForItem:1 inSection:1]] withRowAnimation:UITableViewRowAnimationRight]; }
… mais de toute façon les animations se produisent clairement en même time (et vraiment évident quand les animations lentes sont activées).
Merci Iducool de m'avoir indiqué l'autre question.
Cela a fonctionné …
[CATransaction begin]; [CATransaction setCompletionBlock:^{ [self.tableView reloadRowsAtIndexPaths:@[ [NSIndexPath indexPathForItem:1 inSection:1]] withRowAnimation:UITableViewRowAnimationRight]; }]; [self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 1)] withRowAnimation:UITableViewRowAnimationLeft]; [CATransaction commit];
Je n'ai pas semblé avoir besoin de beginUpdates
et endUpdates
.