从 DetailView 重新加载 MasterView 中的数据
我之前在 iPhone 上遇到了类似的问题,但相同的解决方案似乎不适用于 iPad 环境。我的目标是调用在 RootViewController 中定义的方法 forceReload
,一旦模态被关闭,它将从 DetailView 重新加载 RootView 中的 countdown_table 数据。当直接从 RootViewController 调用时,forceReload 工作正常,但我似乎无法从 DetailView 指向 RootViewController。
我尝试过使用
RootViewController *root_view = [self.splitViewController.viewControllers objectAtIndex:0];
[root_view forceReload];
[root_view.countdown_table reloadData];
But that only point to the Navigation Controller,而不是其中的 View Controller。即使模式被关闭,RootViewController 的 viewWillAppear 也不会触发。
我怎样才能指向这个文件? 谢谢!
I ran into an issue similar to this earlier on the iPhone, but the same solution doesn't seem to apply to the iPad environment. My goal is to call my method forceReload
, defined in my RootViewController, that will reload the countdown_table's data in the RootView from the DetailView once a modal is dismissed. forceReload
works fine when called directly from the RootViewController, but I can't seem to point to point to the RootViewController from the DetailView.
I've tried using
RootViewController *root_view = [self.splitViewController.viewControllers objectAtIndex:0];
[root_view forceReload];
[root_view.countdown_table reloadData];
But that only points to the Navigation Controller, not the View Controller inside of it. Even when the modal is dismissed, RootViewController's viewWillAppear does not fire.
How can I point to this file?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用通知,即将 RootViewController 注册为 DetailView 或任何视图可能发送的通知的观察者。
在 RootViewController 的 viewDidLoad:
viewDidUnload 或 dealloc:
中,并在 DetailViewController 或模态视图中(你没有说它们是相同的),在关闭视图之前或恰好在需要 RootViewController 调用 forceReload 时将其放置:
Try using notifications, i.e., register RootViewController as an observer for notifications that your DetailView or any view may send.
in RootViewController's viewDidLoad:
viewDidUnload or in dealloc:
And in your DetailViewController or your modal view (you didn't say they're the same), put this right before you dismiss the view or exactly when you need RootViewController to call forceReload: