简体   繁体   中英

Tableview reload row after come back tableview

I am trying to reload row after come back to tableview.

In first reload tableview I can reload row with below code and data effected.

let indexPath = IndexPath(row: 2, section: 0)
        tableView.reloadRows(at: [indexPath], with: UITableViewRowAnimation.automatic)

When I come to previous view with back button and then open same tableview again I can not reload row.

Code is working I can see when reload code calls cellForRowAt indexPath function but data not effect it.

Any one has any idea?

Try to do same code in viewWillAppear function. Something like

override func viewWillAppear(_ animated: Bool) {
        tableView.reloadRows(at: [indexPath], with: UITableViewRowAnimation.automatic)
    }

But you need to pass back information about what indexPath was clicked.

试试这个,肯定会起作用。

self.tableView.estimatedRowHeight = 0; self.tableView.estimatedSectionHeaderHeight = 0; self.tableView.estimatedSectionFooterHeight = 0;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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