简体   繁体   English

在tableview重新加载时未调用viewForHeaderInSection

[英]viewForHeaderInSection not called on tableview reload

I have 2 view controllers A and B, view for viewForHeaderInSection is loading properly first time, I have a segue to connect to View B, when I click Back button on navigation bar from view B, View A loads, but if I click on section header its crashing. 我有2个视图控制器A和B,viewForHeaderInSection的视图第一次正确加载,当我单击视图B的导航栏上的“后退”按钮时,我有一个连接到视图B的视图,但是如果我单击“标头崩溃了。 upon debugging I noticed, viewForHeaderInSection is not called on reload. 调试后,我注意到,重新加载时未调用viewForHeaderInSection。

I added self.tableView.delegate = self to onViewDidLoad() function, it doesn't seem to work, I have heightForHeaderInSection properly defined. 我在onViewDidLoad()函数中添加了self.tableView.delegate = self,它似乎不起作用,我已经正确定义了heightForHeaderInSection。

Why it is not being called on reload only? 为什么不只在重新加载时调用它? help please. 请帮助。

This method only works correctly when tableView(_:heightForHeaderInSection:) is also implemented. 仅当还实现了tableView(_:heightForHeaderInSection :)时,此方法才能正常工作。 (From documentation) (来自文档)

Use viewDidAppear to reload what's necessary instead, cause if you hit back, the view is presented from heap memory. 使用viewDidAppear重新加载必要的内容,因为如果您回击,则视图是从堆内存中显示的。

Hope it helps 希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM