Ale można przeładować tylko sekcje, które zawierają tę samą liczbę wierszy(lub musisz ręcznie dodać lub usunąć). W przeciwnym wypadku dostaniesz:
*** 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).'
co nie jest wymagane w przypadku korzystania [tableView reloadData]
.
Kiedy trzeba przeładować sekcję i zmieniły liczbę wierszy wewnątrz niego, można użyć coś takiego:
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:section];
[self beginUpdates];
[self deleteSections:indexSet withRowAnimation:rowAnimation];
[self insertSections:indexSet withRowAnimation:rowAnimation];
[self endUpdates];
Jeśli umieścisz go w kategorii (jak pokazuje bandejapaisa) go może wyglądać tak:
- (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];
}
Wywołanie reloadData jeszcze tylko początkowo przeładować UITableViewCells które są na ekran –
możliwym duplikatu http://stackoverflow.com/ pytania/3485162/reloading-only-one-uitableviewcell-on-a-uitableview –
thanx steve jobs for ur help –