iPhone重新加载表数据
我正在尝试更新表视图控制器中的列表。在该特定表视图控制器中的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否也更改了数据源?
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 intableView:cellForRowAtIndexPath:
, your have to change the array values befor calling reloadData.