无法禁用 UITableView Grouped 中部分的页脚

问题描述 投票:0回答:3

我正在使用

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 部分的页脚没有被隐藏。

这是截图:

请帮忙!

ios swift uitableview
3个回答
5
投票

如果您使用

grouped tableview
,那么总会有页脚,并且它永远不会接受
0 value
。但您可以返回
0.5
1
来解决您的问题,无需覆盖
viewForFooterInSection


1
投票

抱歉各位打扰了,我所做的是我还隐藏了没有任何行的部分和标题。

因此,当我在

UIView()
中返回空
viewForHeaderInSection
时,其中一个标题并未被隐藏。虽然对于没有行的部分,我在
heightForHeaderInSection
中返回 0。

问题现已解决,因为我正在

nil
中返回
viewForHeaderInSection

截图:


0
投票

寻找更干净、精确的解决方案的人应该执行以下操作

func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { nil }

func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { .leastNonzeroMagnitude }
© www.soinside.com 2019 - 2024. All rights reserved.