我想隱藏我的表格視圖中的特定單元格?隱藏我的表格中的特定單元格
private var yourDataSource = [AccountData.AllTasksDB] //A Json Array originally
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{
var rowHeight:CGFloat = 72
//AccountData.AllTasksDB[indexPath.row]["importantvariable"]
if (self.yourDataSource[indexPath.row]["importantvarible"] == "0")
{
print("Cell is mine")
rowHeight = 0
}
else
{
print("Cell is not mine")
rowHeight = 72.0
}
return rowHeight
}
誰能告訴我我做錯了什麼?我認爲它是循環遍歷每個單元格並檢查我已經設置的一個值。但它似乎並不想訪問它。
我建議節省您想隱藏,然後重新加載表來確定的rowHeight – Nathaniel
'的tableView細胞(S)的indexPath .cellForRowAtIndexPath(indexPath)''可能會返回nil,因爲單元格已經出隊...... – Nathaniel
示例:'fileprivate var self.hiddenCellIndexes.contains:[IndexPath]'然後在您的tableView中的heightForRow委託:'if self.hiddenCellIndexes.contains indexPath)' – Nathaniel