ठीक दोस्तों पर केवल एक UITableViewCell को फिर से लोड करना, यहां मेरी स्थिति है।UITableview
मैं कोर डेटा के साथ एक UITableViewController का उपयोग कर रहा हूँ। तालिका में लगभग 200 कोशिकाएं हैं, जो मूल रूप से चेकलिस्ट के रूप में कार्य करती हैं। जब आप किसी सेल को टैप करते हैं, तो उस सेल में एक चेकबॉक्स होता है जो UITableViewCell.imageView पर सेट टॉगल हो जाता है (UIImageView लेबल के बाईं ओर असाइन किया गया है)।
जब भी मैं तालिका को अद्यतन करने के लिए नीचे दिए गए दो तरीकों में से किसी एक का उपयोग करता हूं, तो अपडेट के लिए लगभग 1 - 2 सेकंड लगते हैं ... और जो मैं कह सकता हूं, उससे प्रत्येक सेल को फिर से लोड करना प्रतीत होता है। मैं केवल उस सेल को कैसे मजबूर कर सकता हूं जिसे अद्यतन करने के लिए अभी टैप किया गया था?
[self.tableView reloadData];
या
- (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];
}
हो क्या आप मॉडल में डेटा अपडेट करते हैं? ऐसा लगता है जैसे सभी कोशिकाओं को अद्यतन किया जाता है। – geon
'-insertSections का दूसरा पैरामीटर: withRowAnimation:', '-deleteSections: withRowAnimation:', '-insertRowsAtIndexPaths: withRowAnimation:', और '-deleteRowsAtIndexPaths: withRowAnimation:' 'BOOL' नहीं हैं; वे एक 'UITableViewRowAnimation' प्रकार – user102008