Update the data of a TableViewController after add item

人走茶凉 提交于 2019-12-13 00:48:31

问题


I have tableView (A) responsible for listing items CoreData and viewController (B) to add new item. To create a ViewController (B) custom, they chose to use the following Present Modally to use presentation Over Current Context to enable transparent background and be able to apply the blur.

  • From tableView (A) press the button to add a new item, the viewController (B) appears.
  • Add a new item and saved in CoreData
  • The viewController (B) execute self.dismissViewControllerAnimated(true, completion: nil) and the display returns to the tableView (B)

The problem is that the table view does not update the data.

Following a post from Stack Overflow resulting in code:

override func viewDidAppear(animated: Bool) {
    self.loadData()
}

But at the back of viewController (B), nothing happens in Xcode does not pass the lines of viewDidAppear.

Can anyone help me?


回答1:


Try this:

 override func viewDidAppear(animated: Bool)
{
    self.yourTableViewName.reloadData()
}


来源:https://stackoverflow.com/questions/33161429/update-the-data-of-a-tableviewcontroller-after-add-item

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!