【发布时间】:2016-09-16 13:45:00
【问题描述】:
我正在使用 UITableViewAutomaticDimension 来设置我的 UITableView 单元格的高度。对于过滤功能,我需要隐藏一些单元格,我将通过将它们的高度设置为 0 来隐藏它们。
但是,当我覆盖 heightForRowAtIndexPath 时,我需要为我想要自动调整大小的行返回一些值。如何设置?
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 50
,
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if shouldHideCell == true{
return 0
}else{
return automaticHeight // I need a value here!!!
}
}
【问题讨论】:
-
好问题。精彩的答案。太好了,不是唯一的一个!谢谢 :-) :-) 100 万张赞成票,如果可以的话。
标签: ios swift uitableview