从详细视图刷新 iPad 主数据
我希望能够根据详细视图控制器中采取的操作刷新应用程序主端的表格。
在本例中,我在左侧(主)侧有一个订单表,该表向下钻取以显示 3 个级别的订单:未结订单、已持有订单和未结订单。发送。因此,如果我“更改”订单的状态(搁置、取消搁置、发送等),我希望能够在主控端反映这一点。有什么想法吗?
从我尝试过的详细视图控制器中的操作按钮:
[[appDelegate.splitViewController.viewControllers objectAtIndex:0] reload];
我
OrdersRootController *orc = [[OrdersRootController alloc] initWithNibName:@"Orders" bundle:nil];
orc = [appDelegate.splitViewController.viewControllers objectAtIndex:0];
[orc.tableView reloadData];
尝试添加通知,但它不起作用。
我在 awakeFromNib: 中添加一个观察者
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshOrders:) name:@"OrderStatusChanged" object:odc];
并按顺序发布:
[[NSNotificationCenter defaultCenter] postNotificationName:@"OrderStatusChanged" object:self];`
但是指定的选择器永远不会触发...我错过了什么?
I'd like to be able to refresh the table on the master side of my app, based on an action taken in my detail view controller.
In this case, I have an orders table on the left (master) side that drills down to show 3 levels of orders: Open, Held & Sent. So, if I "change" the status of an order (put it on hold, take it off of hold, send it, etc.) I'd like to be able to reflect that on the master side. Any ideas?
From an action button in the detail view controller I've tried:
[[appDelegate.splitViewController.viewControllers objectAtIndex:0] reload];
and
OrdersRootController *orc = [[OrdersRootController alloc] initWithNibName:@"Orders" bundle:nil];
orc = [appDelegate.splitViewController.viewControllers objectAtIndex:0];
[orc.tableView reloadData];
I tried to add a notification but it's not working.
I'm adding an observer in awakeFromNib:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshOrders:) name:@"OrderStatusChanged" object:odc];
And posting from the order:
[[NSNotificationCenter defaultCenter] postNotificationName:@"OrderStatusChanged" object:self];`
But the selector specified never fires... What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
虽然你已经选择了答案..
在 DetailView 中的任何位置调用此方法:
Although you already chose an answer..
Call this anywhere in your DetailView:
我会将详细视图中表视图的引用(可能在 AppDelegate 中)传递给主视图,并直接调用表重新加载数据。
或者您可以使用通知,主视图发出通知,详细视图通过加载适当的数据进行响应。
I would pass a reference (possibly in the AppDelegate) to the table view in the detail view to the master view, and directly call the table reload data.
Or you can use notifications, the master view raises a notification and the detail view responds by loading the appropriate data.
如果您使用默认的 splitview 控制器,您可以执行此操作
If you are using the default splitview contoller you can do this