添加 Core Data 对象后 tableView 未更新

发布于 2024-12-23 08:27:01 字数 226 浏览 4 评论 0原文

给定这个核心数据模型:摄影师<-->>照片。

通过模态视图添加摄影师后,摄影师的 tableView 会相应更新。

问题是,它对照片的作用不同。我可以通过模态视图添加照片,并且该特定摄影师的照片的表视图不会立即更新。一旦我导航回摄影师的表格视图并再次选择同一摄影师,它就会按预期更新。

当模态视图(用户添加对象的位置)被关闭时,如何让照片的 tableView 立即更新?

Given this Core Data Model: Photographer <-->>Photos.

After adding a Photographer via a Modal View, the tableView of Photographers updates accordingly.

The problem is, that it doesn't do the same for Photos. I can add a Photo via a Modal View, and the tableView of Photos for that particular Photographer does not update immediately. Once I navigate back to the tableView of Photographers and select the same Photographer again, it updates as expected.

How can I get the tableView of Photos to update as soon as the Modal View(where the user added the object) gets dismissed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

別甾虛僞 2024-12-30 08:27:02

模态视图解雇尝试使用的地方:

[tableView reloadData];

Where modal view dismiss try to use:

[tableView reloadData];
霊感 2024-12-30 08:27:02

获得新数据后尝试

 [tableview reload];

方法。

Try

 [tableview reload];

method after getting new data.

薄荷→糖丶微凉 2024-12-30 08:27:02
  1. 检查您的错误变量是否包含错误。
  2. 您直接将 -executeFetchRequest:error: 的结果分配给 ivar (photographerPhotosArray)。这要么泄漏,要么导致立即释放。
  3. 考虑切换到 NSFetchedResultsController 因为它对你有很大帮助。
  1. Check your error variable if it contains an error.
  2. You directly assign the result of -executeFetchRequest:error: to an ivar (photographerPhotosArray). This either leaks or causes an immediate release.
  3. Consider switching to NSFetchedResultsController since it helps you a lot.
奈何桥上唱咆哮 2024-12-30 08:27:02

首先检查你的数组是满的还是空的?尝试使用 NSLog 并检查它。如果存在则重新加载表

Check your array first is it fill or empty? try with NSLog and check it. if it exist then reload your table

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文