>我正在尝试在返回表视图后重新加载行。
在第一次重新加载表视图中,我可以重新加载行,并使用以下代码和数据受到影响。
let indexPath = IndexPath(row: 2, section: 0)
tableView.reloadRows(at: [indexPath], with: UITableViewRowAnimation.automatic)
当我使用后退按钮进入上一个视图,然后再次打开相同的表视图时,我无法重新加载行。
代码正在工作,我可以看到何时重新加载代码调用cellForRowAt indexPath函数,但数据不会影响它。
有人知道吗?
尝试在viewWillAppear函数中执行相同的代码。类似的东西
override func viewWillAppear(_ animated: Bool) {
tableView.reloadRows(at: [indexPath], with: UITableViewRowAnimation.automatic)
}
但是您需要传回有关单击了哪个 indexPath 的信息。
试试这个它肯定会起作用。
self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;