Nhưng bạn có thể tải lại chỉ phần mà chứa cùng một số hàng(hoặc bạn phải tự thêm hoặc xóa chúng). Nếu không, bạn sẽ nhận được:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 2. The number of rows contained in an existing section after the update (1) must be equal to the number of rows contained in that section before the update (0), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
nào là không cần thiết khi bạn sử dụng [tableView reloadData]
.
Khi bạn cần phải tải lại một phần và bạn đã thay đổi số hàng bên trong nó, bạn có thể sử dụng một cái gì đó như thế này:
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:section];
[self beginUpdates];
[self deleteSections:indexSet withRowAnimation:rowAnimation];
[self insertSections:indexSet withRowAnimation:rowAnimation];
[self endUpdates];
Nếu bạn đặt nó trong một thể loại (như chương trình bandejapaisa) nó có thể trông giống như sau:
- (void)reloadSection:(NSInteger)section withRowAnimation:(UITableViewRowAnimation)rowAnimation {
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:section];
[self beginUpdates];
[self deleteSections:indexSet withRowAnimation:rowAnimation];
[self insertSections:indexSet withRowAnimation:rowAnimation];
[self endUpdates];
}
Calling reloadData vẫn chỉ ban đầu sẽ tải lại UITableViewCells có trên màn hình –
trùng lặp có thể xảy ra http://stackoverflow.com/ câu hỏi/3485162/tải lại-chỉ-một-uitableviewcell-on-a-uitableview –
thanx steve việc làm cho ur giúp –