【发布时间】:2019-11-03 19:21:17
【问题描述】:
我想更改表格视图中第一个(顶部 = 索引 0)单元格的高度,同时保持所有其他单元格的高度相同。
我该怎么做?
理想情况下,我希望能够在这里做到这一点:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if shouldDisplaySuggestions && indexPath.row == 0 {
let cell = UITableViewCell(style: .default, reuseIdentifier: "cell")
cell.textLabel?.text = "help"
cell.textLabel?.font = UIFont(name: "SFCompactDisplay-Semibold", size: 17)
return cell
}
我将所有其他单元格设置为:
tableView.rowHeight = 64.07
而这并不存在 ->
tableView.cellForRow(at: IndexPath(row: 0, section: 0)).row...
【问题讨论】:
-
这就是
heightForRowAt方法的用途。 -
为什么行高为
64.07?为什么不只是64? -
我喜欢完美的设计,尽管我认为无论如何它都是默认的,在这种情况下我还不如对吧? @rmaddy
标签: ios swift uitableview uikit row-height