2014-06-11 100 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]; 

修復問題

相關問題