iPhone重新加载表数据

发布于 2024-08-18 07:08:33 字数 351 浏览 4 评论 0原文

我正在尝试更新表视图控制器中的列表。在该特定表视图控制器中的 viewWillAppear 中,使用以下代码设置 tableView:

[self.tableView reloadData];

我试图从另一个类(DetailViewController)进行此刷新,它引用另一个视图控制器。 在 DetailViewController 中的方法中,我想重新加载 JobsViewController 中的数据,但无法执行此操作。我可以想象下面的代码可以工作,但仍然缺少一些东西。谁能解释一下吗?

[JobsViewController.tableView reloadData];

I am trying to update a list in a tableview controller. In viewWillAppear in that particular tableview controller, the tableView is setup with the code:

[self.tableView reloadData];

I am trying to do this refresh from an other Class (DetailViewController), which refers to another view controller.
In a method in DetailViewController I want to reload the data in JobsViewController, but can't do it. I can envision the below code working, but something is still missing. Can anyone please shed some light on this?

[JobsViewController.tableView reloadData];

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

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

发布评论

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

评论(1

辞慾 2024-08-25 07:08:33

您是否也更改了数据源? reloadData 仅重新加载单元格。它不负责实际更新底层数据源。例如,如果您从 tableView:cellForRowAtIndexPath: 中的数组读取数据,则必须在调用 reloadData 之前更改数组值。

Did you also change your data source? reloadData does only reload the cells. It doesn't take care of actually updating the underlying datasource. E.g. if you read data from an array in tableView:cellForRowAtIndexPath:, your have to change the array values befor calling reloadData.

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