Reload UITableView when navigating back?

前端 未结 7 1694
醉梦人生
醉梦人生 2021-01-30 06:38

I have a top level UIViewController that contains a UITableView. The top level UIViewController instantiates a NavigationController

7条回答
  •  遇见更好的自我
    2021-01-30 06:55

    Maybe can help now.

    For Swift 2+

    In your viewDidAppear method:

    If you want to reload all table:

    tableView.reloadData()
    

    If you want to reload only the cell selected.

    let index = tableView.indexPathForSelectedRow
    if (index != nil){
      self.tableView.reloadRowsAtIndexPaths([index], withRowAnimation: UITableViewRowAnimation.Automatic)
    }
    

提交回复
热议问题