我正在使用
UITableView
分组并使用多个部分。我正在使用这些代码来隐藏部分的页脚。
self.tableView.estimatedSectionFooterHeight = 0
self.tableView.sectionFooterHeight = 0
public func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.0
}
public func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
只有第 0 部分的页脚没有被隐藏。
这是截图:
请帮忙!
如果您使用
grouped tableview
,那么总会有页脚,并且它永远不会接受0 value
。但您可以返回 0.5
或 1
来解决您的问题,无需覆盖 viewForFooterInSection
寻找更干净、精确的解决方案的人应该执行以下操作
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { nil }
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { .leastNonzeroMagnitude }