单击时如何避免单元格分隔符消失

时间:2016-09-07 06:39:28

标签: ios swift uitableview

以这种方式单击单元格时,我已完成单元格扩展。

didSelectRowatIndex

中的

self.tblPlaylist.cellForRowAtIndexPath(indexPath)?.backgroundColor = UIColor.grayColor()
self.tblPlaylist.separatorColor=UIColor(white: 1, alpha: 0.3)

// avoid paint the cell is the index is outside the bounds
if self.selectedRowIndex != -1 {
    self.tblPlaylist.cellForRowAtIndexPath(NSIndexPath(forRow: self.selectedRowIndex, inSection: 0))?.backgroundColor = UIColor.clearColor()
}

if selectedRowIndex != indexPath.row {
    self.thereIsCellTapped = true
    self.selectedRowIndex = indexPath.row
}
else {
    // there is no cell selected anymore
    self.thereIsCellTapped = false
    self.selectedRowIndex = -1
}

self.tblPlaylist.beginUpdates()
self.tblPlaylist.endUpdates()

in heightForrowAtIndex方法

if (indexPath.row == selectedRowIndex && thereIsCellTapped) {
    return 100
}
return 70

细胞扩张发生。但我的问题是当我敲击一个牢房时,它上面的分离器就消失了。然后,如果我将上面的单元格轻敲到当前分接的单元格或任何其他分隔符再次加载的单元格。我怎么能阻止它消失细胞分离器。

1 个答案:

答案 0 :(得分:1)

请勿使用默认分隔符。使用适当的约束在单元格内创建一个UIView,你不会有任何类似的问题。

相关问题