我有一个静态单元格的 TableView(具有不同的高度),我试图在加载时隐藏一个单元格。我通过使用 heightForRowAtIndexPath
并为我要关闭的单元格返回 0
来实现它,但是,对于该函数,我需要返回一个值..
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if indexPath.section == 2 && indexPath.row == 5 {
return 0
}
// here:
return tableView.rowHeight // changes default values of cells
return UITableViewAutomaticDimension // changes too.
}
我想返回单元格的任何高度。
我为 obj-c 找到了这个,我觉得它可以工作,但我不确定..我无法翻译它..
[super tableView:tableView heightForRowAtIndexPath:indexPath];
保持单元格高度的方法是什么?我应该对所有内容进行硬编码吗?
最佳答案
只需调用super
实现即可:
return super.tableView(tableView, heightForRowAtIndexPath: indexPath)
关于ios - 保持一些单元格高度不变,同时改变其他的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36946951/