我有 tableView
,在 Storyboard中设置了一个部分和页脚。我正在尝试使用以下代码更改 viewDidLoad()
中表格的 footerView
中的文本
tableView.footerView(forSection: 0)?.textLabel?.text = "Testing text"
但是 tableView.footerView(forSection: 0) == nil
然后在用户点击按钮时,我使用相同的代码调用更改 footerView 文本的函数,它完美地工作。
func changeFooterText() {
tableView.footerView(forSection: 0)?.textLabel?.text = "Testing text after tap"
}
为什么 viewDidLoad
中不存在 footerView
?如何在 viewDidLoad
中更改它的文本?还是我应该在其他地方更改它?加载屏幕后,我需要在页脚中显示取决于屏幕上其他数据的文本。
期待阅读您的建议。
最佳答案
您可以使用表脚 View 方法:
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView?
关于ios - 为什么 tableView 的 FooterView 在 viewDidLoad() 中不存在,如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52210206/