проблемы с анимацией при удалении последней строки TableView в ios7
у меня возникли некоторые проблемы при удалении последней строки моего (только) раздела в моемtableView
, Любая другая строка работает нормально, но если я удалю строку в нижней части моегоtableView
в любое время (а не только когда он ушел последним) анимация очень странная и медленная. Это просто нене выглядит правильно. Я'Мы также заметили, что изменение типа анимации неничего не делай. Анимация всегда, когда строка скользит вверх и исчезает. Меняя его наUITableViewRowAnimationFade
или другой неничего не делай.
Вот мой код
//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);
}
}];
}
}
Я посмотрел на каждый ответ, который я могу найти без удачи. Я возвращаю 1 в моемnumberOfSections
вtableview
потому что мне нужен только один раздел, и я должен иметь возможность иметь 0 строк в разделе, поэтому я нене думаю, чтоС проблемой.