Ok les gars, voici la situation que j'ai. J'utilise un UITableViewController avec Core Data. La table a environ 200 cellules, qui fonctionnent essentiellement comme une liste de contrôle. Lorsque vous appuyez sur une cellule, cette case possède une case à cocher qui est basculée sur UITableViewCell.imageView (UIImageView affecté à gauche de l'étiquette).Rechargement d'un seul UITableViewCell sur un UITableview
Chaque fois que j'utilise l'une des deux méthodes ci-dessous pour mettre à jour la table, cela prend environ 1 à 2 secondes pour la mise à jour ... et je sais qu'il semble recharger chaque cellule. Comment puis-je forcer uniquement la mise à jour de la cellule qui vient d'être tapée?
[self.tableView reloadData];
ou
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
[self.tableView beginUpdates];
}
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo
atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type {
switch(type) {
case NSFetchedResultsChangeInsert:
[self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex]
withRowAnimation:NO];
break;
case NSFetchedResultsChangeDelete:
[self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex]
withRowAnimation:NO];
break;
}
}
- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
newIndexPath:(NSIndexPath *)newIndexPath {
UITableView *tableView = self.tableView;
switch(type) {
case NSFetchedResultsChangeInsert:
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]
withRowAnimation:NO];
break;
case NSFetchedResultsChangeDelete:
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:NO];
break;
case NSFetchedResultsChangeUpdate:
[self configureCell:[tableView cellForRowAtIndexPath:indexPath]
atIndexPath:indexPath];
break;
case NSFetchedResultsChangeMove:
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:NO];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]
withRowAnimation:NO];
break;
}
}
- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
[self.tableView endUpdates];
}
Ho w mettez-vous à jour les données dans le modèle? Il semble que toutes les cellules soient mises à jour. – geon
le second paramètre de '-insertSections: withRowAnimation:', '-deleteSections: withRowAnimation:', '-insertRowsAtIndexPaths: withRowAnimation:', et '-deleteRowsAtIndexPaths: withRowAnimation:' ne sont pas 'BOOL'; ils sont un type 'UITableViewRowAnimation' – user102008