gpt4 book ai didi

ios - UITables 部分标题中的多行文本

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:53:27 26 4
gpt4 key购买 nike

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

enter image description here

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

我目前正在尝试的是:

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

但它并没有产生任何影响。谁能帮帮我?

最佳答案

代替

tableView.estimatedRowHeight = 44.0
tableView.rowHeight = UITableViewAutomaticDimension

在下面使用

tableView.sectionHeaderHeight = UITableViewAutomaticDimension
tableView.estimatedSectionHeaderHeight = 44

更多信息请阅读下面的答案 https://stackoverflow.com/a/29763200/1320352

关于ios - UITables 部分标题中的多行文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48892111/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com