【发布时间】:2018-04-29 15:45:36
【问题描述】:
我正在尝试根据标识符设置表格视图中每个单元格的高度。我不想使用 indexPath.row,因为我正在从包含每种类型单元格的标志的数组中填充单元格,并且顺序是随机的。正好 3 种类型的细胞。
我使用了这段代码,但它导致了错误:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let cell = tableV.cellForRow(at: indexPath)
if(cell?.reuseIdentifier == "homeFeaturedR"){
return 200
}else{
return 360
}
}
错误在这一行:
let cell = tableV.cellForRow(at: indexPath)
谢谢。
【问题讨论】:
-
您可以使用数据源数组的标志返回单元格高度!
标签: ios swift uitableview height row