2016-09-07 59 views
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 

細胞擴增發生。但是我的問題是當我敲擊一個單元格時,它上面的分隔符正在消失。然後如果我將上面的單元點擊到當前分接單元或分隔單元再次加載的單元之外。我怎樣才能阻止這種細胞分裂者的消失。

回答

1

請勿使用默認分隔符。用適當的約束在你的單元格內創建一個UIView,你不會有這樣的問題。

+0

感謝您的建議。我爲分隔者製作了一條自定義線路。但是當我的細胞擴張時,它仍然處於相同的位置。我需要改變它的框架?在哪個代表中。當單元格展開時,我的線條應該在收縮時增加Y,Y應該減小 – Irrd

+0

您可以使用自動佈局並設置底部約束或覆蓋'-layoutSubviews'方法並設置分隔符的框架。 – graver