【问题标题】:Hide First TableView Section header height iOS 11隐藏第一个 TableView 部分标题高度 iOS 11
【发布时间】:2018-01-23 07:21:14
【问题描述】:

self.tableView.estimatedSectionHeaderHeight = 20.0
self.tableView.contentInset = UIEdgeInsetsMake(-18.0, 0.0, 0.0, 0.0)

对于 iOS 11,什么应该有效? 我尝试将第 0 部分从titleForHeaderInSection 设置为“nil”,并将第一部分的 heightForHeaderInSection 设置为“0”,但没有成功。

【问题讨论】:

  • 尝试设置section header height = 0.1
  • 你有多少个部分?
  • @AndreaMugnaini 3
  • self.tableView.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 0.01)) 试试这个

标签: ios swift uitableview


【解决方案1】:

试试这个

仅此一项不会显示部分标题:

func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
    return nil
}

这将显示一个没有标题的节标题:

func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
    return nil
}

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

【讨论】:

    【解决方案2】:

    在iOS11中follow方法无效

    1.controller.automaticallyAdjustsScrollViewInsets = false

    您可以使用follow方法替换

    2.controller.view.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;

    如果还是不行,你可以写下后续代码

    3.tableView.tableHeaderView = UIView.init();

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-02
      • 1970-01-01
      • 1970-01-01
      • 2017-04-24
      • 2013-07-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多