我想隐藏我的表格视图中的特定单元格?隐藏我的表格中的特定单元格
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