0
このようにセルをクリックするとセルが伸びてしまいました。クリックするとセルセパレータが消えないようにする方法
if (indexPath.row == selectedRowIndex && thereIsCellTapped) {
return 100
}
return 70
heightForrowAtIndex方法で
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()
didSelectRowatIndex
における細胞拡張手段起こります。しかし、私の問題は、セルをタップすると、上のセパレータが消えてしまうことです。それからもし私が上記のセルを現在タップされているセルまたはセパレータが再びロードするセル以外のセルにタップした場合。どのように私はこれを止めることができますセルの分離器を消滅させる。
提案していただきありがとうございます。私はセパレータのカスタムラインを作った。しかし、私の細胞が膨張すると、それは同じ位置にとどまります。どこのフレームを変更する必要がありますか?どの代議員に。セルが展開されるときに、Yを縮小するときにYを大きくする必要があります。Yを小さくする必要があります。 – Irrd
autolayoutを使用してbottom制約を設定するか、-layoutSubviewsメソッドをオーバーライドしてセパレータのフレームを設定します。 – graver