当用户在this tutorial之后滚动时,我正在尝试更改标题视图的高度。但是,当我尝试访问IF
(所以我可以更新标题视图的高度)时,值为nil,调试器告诉我“标题视图没有高度”。我使用self.songsTable.headerView(forSection: 0)?.frame.size.height
和heightForHeaderInSection
以编程方式创建了标题视图。
代码
viewForHeaderInSection
答案 0 :(得分:0)
您的代码段可能只是缺少这个,但您是否将viewController设置为TableViewDataSource?
class SongsViewController: UIViewController, UITableViewDataSource {
override func viewDidLoad() {
super.viewDidLoad()
songsTable.dataSource = self
}
// ... the rest of your code ...
}