Ios 如何在UITableView中获取动态大小的节标题的高度?
我有一个Ios 如何在UITableView中获取动态大小的节标题的高度?,ios,swift,uitableview,Ios,Swift,Uitableview,我有一个UITableView,它使用自定义UIView作为节头视图。代码如下: func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { return UITableViewAutomaticDimension } func tableView(_ tableView: UITableView, viewForHeaderInSection section
UITableView
,它使用自定义UIView
作为节头视图。代码如下:
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
}
您可以取出标题视图的高度,如下所示
if let headerView = tableView.tableHeaderView {
height = headerView.systemLayoutSizeFitting(UILayoutFittingCompressedSize).height
}
可能是
tableView.headerView(第0节)?高度?只是不确定你想在哪里得到高度