override 所在UIViewController的 viewDidLayoutSubviews方法
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
if let footView = tableView.tableFooterView {
//footerContentView 是footerView的内容视图,它使用自动布局来自适应高度,然后在代码里面获取高度变更footerView 的高度
let height = footerContentView.systemLayoutSizeFittingSize(UILayoutFittingCompressedSize).height
if height != footerView.frame.height {
print("new height=\(height)")
footView.frame.size.height = height
tableView.tableFooterView = footView
}
}
}