[英]iPad SplitViewController: Reloading the root view controller's tableview from the detail view controller
I've searched this site and the web and just looking for a simple example on how to reload the root view controller's table view from the detail view. 我已经搜索了该站点和Web,只是在寻找一个有关如何从详细信息视图重新加载根视图控制器的表视图的简单示例。 I've tried notifications, setting a tableview in the detailview controller equal to the tableview of the rootview controller...nothing works.
我已经尝试过通知,在detailview控制器中将tableview设置为与rootview控制器的tableview相等……没有任何作用。
Has anyone experienced this or have any sample code? 有没有人经历过或有任何示例代码?
Use notificationcenter to pass a notification from the detail to the rootviewcontroller telling it to reload the data. 使用notificationcenter将通知从详细信息传递到rootviewcontroller,告诉它重新加载数据。
ex: IN ROOT VIEW CONTROLLER 例如:在根视图控制器中
(where i've created a method called reloadRootTable, that calls [self.tableView reloadData];
) (在这里我创建了一个名为reloadRootTable的方法,该方法调用
[self.tableView reloadData];
)
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadRootTable) name:@"reloadRootTable" object:nil];
}
- (void)viewWillDisappear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"reloadRootTable" object:nil];
[super viewWillDisappear:animated];
}
IN DETAILVIEWCONTROLLER: 在DETAILVIEWCONTROLLER中:
[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadRootTable" object:nil];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.