如何重新加载UITableView中的sectionHeader标题?

如何重新加载UITableView中的sectionHeader标题?

问题描述:

我想重新加载方法:func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String?,只刷新标题。但不想重新加载整个tableView。有没有办法做到这一点?如何重新加载UITableView中的sectionHeader标题?

据我所知你不能只重新加载sectionHeader。 你能做的最好的就是重新加载包含使用

self.tableView.reloadSections([1], with: .automatic)

,其中1节,你想更新的索引头部分。通过您想要重新加载的部分的索引。

希望它可以帮助

当然你也可以直接调用该方法,像这样的:

self.tableView(self.tableView, titleForHeaderInSection: 1) 

让我知道,如果这有助于。

let header = table.headerView(forSection: 0) as! URCutomHeaderView 
header.someMethod()//configure new data