0
当按这种方式点击细胞时,我已经完成了细胞扩展。如何避免点击时消失细胞分离器
在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()
在heightForrowAtIndex方法
if (indexPath.row == selectedRowIndex && thereIsCellTapped) {
return 100
}
return 70
细胞扩增发生。但是我的问题是当我敲击一个单元格时,它上面的分隔符正在消失。然后如果我将上面的单元点击到当前分接单元或分隔单元再次加载的单元之外。我怎样才能阻止这种细胞分裂者的消失。
感谢您的建议。我为分隔者制作了一条自定义线路。但是当我的细胞扩张时,它仍然处于相同的位置。我需要改变它的框架?在哪个代表中。当单元格展开时,我的线条应该在收缩时增加Y,Y应该减小 – Irrd
您可以使用自动布局并设置底部约束或覆盖'-layoutSubviews'方法并设置分隔符的框架。 – graver