我试图在分组的 tableView 中包含页眉,但没有页脚。我正在创建 header :
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "Header") as! DateHeaderTableViewHeaderFooterView
...
return headerView
}
我已经在 Storyboard中设置了 tableView 以对所有单元格以及页眉和页脚使用自动尺寸。
我假设因为我没有提供任何页脚,所以它们不会存在,但是每个部分都添加了页脚。此外,所有页眉和页脚都有灰色背景。
我尝试取消选中页脚自动尺寸并选择一个值,但它可以接受的最低值为 1,但页脚仍然显示。
我怎样才能有页眉但没有页脚并更改页眉的背景颜色?
我可以使用普通的 tableView 实现我想要的,但是标题被固定在我试图避免的顶部。
最佳答案
您需要实现以下方法:
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return CGFloat.leastNormalMagnitude
}
关于ios - 在具有自动尺寸的分组 tableView 中显示页眉而不是页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47038138/