problemy z animacją podczas usuwania ostatniego wiersza TableView w ios7
Mam pewne problemy podczas usuwania ostatniego wiersza mojej (tylko) sekcji w moimtableView
. Każdy inny wiersz działa dobrze, ale jeśli usunę wiersz na dole mojegotableView
w każdej chwili (nie tylko wtedy, gdy pozostało jej ostatnie) animacja jest bardzo dziwna i opóźniona. To po prostu nie wygląda dobrze. Zauważyłem również, że zmiana typu animacji nic nie robi. Animacja jest zawsze, gdy rząd przesuwa się w górę i znika. Zmiana naUITableViewRowAnimationFade
lub inny nic nie robi.
Oto mój kod
//For the edit barButtonItem in my storyboard
- (IBAction)editButtonPressed:(id)sender {
//enter editing mode
if ([self.editButton.title isEqualToString:@"Edit"]) {
[self setEditing:YES animated:YES];
self.editButton.title = @"Done";
} else {
[self setEditing:NO animated:YES];
self.editButton.title = @"Edit";
}
}
//Editing the tableView. The user can only delete rows, not add any
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleDelete;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
// If row is deleted, remove it from the list.
if (editingStyle == UITableViewCellEditingStyleDelete) {
//Handle the data source and backend first, then the tableView row
PFRelation *hasFavorites = [self.currentUser relationforKey:@"hasFavorites"];
[hasFavorites removeObject:[self.favorites objectAtIndex:indexPath.row]];
[self.favorites removeObjectAtIndex:indexPath.row];
//It is set to fade here, but it only ever does the top animation
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
//save to the backend
[self.currentUser saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
} else {
NSLog(@"%@ %@", error, error.userInfo);
}
}];
}
}
Przyjrzałem się każdej odpowiedzi, którą mogę znaleźć bez powodzenia. Wracam 1 w moimnumberOfSections
wtableview
ponieważ chcę mieć tylko jedną sekcję i powinienem mieć 0 wierszy w sekcji, więc nie sądzę, aby to był problem.