Jeśli wywołasz reloadRowsAtIndexPaths dla pierwszej komórki sekcji, z poprzednią sekcją pustą, a ta powyżej niepustą, dostaję dziwny błąd animacji (nawet jeśli podaję "UITableViewRowAnimationNone"), gdzie przeładowana komórka ześlizguje się z powyższej sekcji ..UITableView reloadRowsAtIndexPaths glitch graficzny
starałem się uprościć przykład jak najwięcej:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0)
return 1;
else if (section == 1)
return 0;
else if (section == 2)
return 3;
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
cell.textLabel.text = @"Text";
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSArray *editedCell = [[NSArray alloc] initWithObjects:indexPath, nil];
//[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:editedCell withRowAnimation:UITableViewRowAnimationNone];
//[self.tableView endUpdates];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return @"Section";
}
Właściwie można Wykomentuj Ostatnia metoda, ale daje lepsze zrozumienie problemu.
To świetne rozwiązanie, tak, jest dziwne zachowanie od reloadRowsAtIndexPaths błąd, lub po prostu używałem go w niewłaściwy sposób? – Fr4ncis
@ Fr4ncis, nie jestem pewien. Aby ponownie załadować widok tabeli komórek, może być konieczne dodanie/usunięcie ich z hierarchii widoków, przebudowanie niektórych jej podekspozycji lub czegoś innego - to zależy od tego, jak wszystkie te transformacje są zaimplementowane wewnętrznie – Vladimir
dziękuję, twoje rozwiązanie jest czyste i dobrze zorganizowane. – jalopezsuarez