[英]Tableview reload row after come back tableview
我试图重新加载行后回到tableview。
在第一个重新加载tableview中,我可以使用以下代码和数据重新加载行。
let indexPath = IndexPath(row: 2, section: 0)
tableView.reloadRows(at: [indexPath], with: UITableViewRowAnimation.automatic)
当我使用后退按钮进入上一个视图,然后再次打开相同的tableview时,我无法重新加载行。
代码可以正常工作,我可以看到重新加载代码何时调用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;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.