gpt4 book ai didi

ios - 如何获取 UITableView 中动态大小的节标题的高度?

转载 作者:行者123 更新时间:2023-11-30 11:17:19 25 4
gpt4 key购买 nike

我有一个 UITableView,它使用自定义的 UIView 作为节标题 View 。代码如下:

func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return UITableViewAutomaticDimension
}

func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "ECStartTableHeaderView") as! ECStartTableHeaderView
return headerView
}

我有 UITableViewAutomaticDimension 作为标题的高度。我需要找出我的代码中的高度。我怎样才能得到这个标题高度?

最佳答案

我认为你必须确保你的标题布局首先完成,这样你才能得到实际的高度。

func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
let height = view.frame.height
}

关于ios - 如何获取 UITableView 中动态大小的节标题的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51624975/

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