添加项目后更新TableViewController的数据 [英] Update the data of a TableViewController after add item

查看:123
本文介绍了添加项目后更新TableViewController的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有tableView(A)负责列出项CoreData和viewController(B)以添加新项.为了创建ViewController(B)自定义,他们选择使用以下模态呈现来使用演示文稿在当前上下文中启用透明背景并能够应用模糊./p>

  • 从tableView(A)中按按钮添加一个新项目,然后显示viewController(B).
  • 添加新项目并保存在CoreData中
  • viewController(B)执行self.dismissViewControllerAnimated(true, completion: nil),显示返回到tableView(B)

问题在于表格视图不会更新数据.

以下来自Stack Overflow的帖子导致代码:

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

但是在viewController(B)的背面,Xcode中没有发生任何事情而没有通过viewDidAppear的行.

有人可以帮助我吗?

解决方案

尝试一下:

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

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?

解决方案

Try this:

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

这篇关于添加项目后更新TableViewController的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆