【问题标题】:Multiline text in UITables section headerUITables 部分标题中的多行文本
【发布时间】:2018-02-20 18:39:02
【问题描述】:

我一直在搜索并尝试让我的 UITableView 部分标题允许多行文本,但我无法让它工作。这是它显示的内容:

但文字是:埃弗顿足球俱乐部的主场球衣是什么颜色的?

我目前正在尝试的是:

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

        let label = UILabel()
        label.lineBreakMode = .byWordWrapping
        label.numberOfLines = 0
        label.text = question?.question
        return label
}

并将以下内容放在viewDidLoad 事件中

tableView.estimatedRowHeight = 44.0
tableView.rowHeight = UITableViewAutomaticDimension

但这并没有什么不同。谁能帮帮我?

【问题讨论】:

标签: ios uitableview


【解决方案1】:

而不是

tableView.estimatedRowHeight = 44.0
tableView.rowHeight = UITableViewAutomaticDimension

在下面使用

tableView.sectionHeaderHeight = UITableViewAutomaticDimension
tableView.estimatedSectionHeaderHeight = 44

欲了解更多信息,请阅读以下答案 https://stackoverflow.com/a/29763200/1320352

【讨论】:

猜你喜欢
  • 2013-01-14
  • 1970-01-01
  • 1970-01-01
  • 2020-03-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多