Ok chicos, esta es la situación que tengo.Recargando solo una UITableViewCell en una UITableview
Estoy usando un UITableViewController con Core Data. La tabla tiene alrededor de 200 celdas, que básicamente funcionan como una lista de verificación. Cuando toca una celda, esa celda tiene una casilla de verificación que se activa o desactiva configurada en UITableViewCell.imageView (el UIImageView asignado a la izquierda de la etiqueta).
Cada vez que uso alguna de las dos formas a continuación para actualizar la tabla, la actualización tarda aproximadamente 1-2 segundos, y por lo que puedo decir, parece que está recargando cada celda. ¿Cómo puedo forzar solo que se actualice la celda que se acaba de tocar?
[self.tableView reloadData];
o
- (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 ¿Cómo actualizas los datos en el modelo? Parece que todas las celdas se actualizan. – geon
el segundo parámetro de '-insertSections: withRowAnimation:', '-deleteSections: withRowAnimation:', '-insertRowsAtIndexPaths: withRowAnimation:', y '-deleteRowsAtIndexPaths: withRowAnimation:' no son 'BOOL'; son un tipo 'UITableViewRowAnimation' – user102008