【发布时间】:2016-04-29 20:29:34
【问题描述】:
我有一个静态单元格(具有不同高度)的 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];
保持单元格高度不变的方法是什么?我应该对所有内容进行硬编码吗?
【问题讨论】:
标签: ios swift uitableview tableviewcell heightforrowatindexpath