2014-06-11 99 views
2

我需要在选定的行下添加一个新行。我使用这个代码在didSelectRowAtIndexPath方法:UITableView insertRowsAtIndexPaths删除单元格分隔符

[_dataSource insertObject:newDataObject atIndex:indexPath.row + 1]; 

NSMutableArray *indexPaths = [NSMutableArray array]; 
NSInteger currentCount = indexPath.row; 
[indexPaths addObject:[NSIndexPath indexPathForRow:currentCount+1 inSection:0]]; 

[self.tableView beginUpdates]; 
[self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone]; 
[self.tableView endUpdates]; 

它增加了在正确的位置的新行,但它还会删除所选行的表面细胞分离器。我究竟做错了什么?

+0

会不会是你的新细胞具有高度不正确? –

+0

不,因为当我在cellForRowAtIndexPath中创建单元格时,我总是使用相同的高度。内容也是一样的。 – Heisenberg

+0

我问过我有一个问题,因为我改变了原型单元格的数量,并且单元格被调整大小:)并且互相重叠 –

回答

3

似乎UITableViewCell在选定状态下没有分隔符。 UITableViewCellSelectionStyleNone只是禁用突出显示,但单元格无论如何都是selected。加入

[tableView beginUpdates]; 
    // insert/delete manipulations 
    [tableView deselectRowAtIndexPath:indexPath animated:NO]; 
    [tableView endUpdates]; 

修复问题

相关问题