当我使用动画重新加载几个单元格时,在其他一些非动画单元格之间会出现空格。然而,最有趣的是它有时会发生,有时却不会发生。以下代码来自tableView委托的didselect函数。
NSArray *taskArray;
int count ;
if (array.count >= indexPath.row+1) {
taskArray = [[dictionary objectForKey:[NSString stringWithFormat:@"Week %i",indexPath.section+1]] objectForKey:[array objectAtIndex:indexPath.row]];
count = [taskArray count];
}else{
count = 0;
}
numberOfAddedRows = count;
selectedRow = -1;
selectedSection = -1;
int numberOfRows = [[[dictionary objectForKey:[NSString stringWithFormat:@"Week %i",indexPath.section+1]] allKeys] count];
[self.tableView beginUpdates];
/*for (int i = numberOfRows-1+numberOfAddedRows; i > indexPath.row; i--) {
[array addObject:[NSIndexPath indexPathForRow:i-1 inSection:indexPath.section]];
}*/
if (!editMode) {
[array__ removeAllObjects];
for (int i = indexPath.row+numberOfAddedRows; indexPath.row < i; i--) {
[array__ addObject:[NSIndexPath indexPathForRow:i inSection:indexPath.section]];
}
[self.tableView deleteRowsAtIndexPaths:array__ withRowAnimation:UITableViewRowAnimationMiddle];
}else{
[array__ removeAllObjects];
for (int i = indexPath.row+numberOfAddedRows+1; indexPath.row < i; i--) {
[array__ addObject:[NSIndexPath indexPathForRow:i inSection:indexPath.section]];
}
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UITextField *textField = (UITextField*)[cell viewWithTag:2];
[textField resignFirstResponder];
[self.tableView deleteRowsAtIndexPaths:array__ withRowAnimation:UITableViewRowAnimationMiddle];
}
[self.tableView endUpdates];
[self.tableView reloadData];
答案 0 :(得分:1)
你为什么要这最后一行?
[self.tableView reloadData];
尝试删除它 - 我认为它会干扰动画。