Nathan187 Nathan187 - 1 year ago 75
iOS Question

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. I've tried notifications, setting a tableview in the detailview controller equal to the tableview of the rootview controller...nothing works.

Has anyone experienced this or have any sample code?

Answer Source

Use notificationcenter to pass a notification from the detail to the rootviewcontroller telling it to reload the data.


(where i've created a method called reloadRootTable, that calls [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];


[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadRootTable" object:nil];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download