我刚刚尝试了下面的代码行,但我无法正常工作。我想知道如何以编程方式为页眉或页脚提供这种情况,可能正在使用自动布局,我不知道究竟是哪一个解决了我的问题。我正在使用 UITableViewHeaderFooterView 的 xib 文件。
如果有人解释我会很棒。
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
// Dynamic sizing for the footer view
if let footerView = tableView.tableFooterView {
let height = footerView.systemLayoutSizeFittingSize(UILayoutFittingCompressedSize).height
var footerFrame = footerView.frame
if height != footerFrame.size.height {
footerFrame.size.height = height
footerView.frame = footerFrame
tableView.tableFooterView = footerView
}
}
}