views:

189

answers:

1

I have two view controllers in a tabbar which can both edit data. Therefore, I need to call a reload_data function whenever the user makes a switch on the tabbar. How can I catch the switch or the appearance of the viewcontroller. Somehow viewDidAppear is not called on a tabbar switch. And I do not want to use the tabbarController delegate for this, because several viewControllers are affected (and I cannot set them all as delegate). What is a good way to solve this?

e.g. this didn't work:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    [self reloadData];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:YES];
    [self reloadData];
}
+1  A: 

If you're using Interface Builder, make sure the class for the viewController your expecting to reload is defined (Select the ViewController in IB, then CMD-4, make sure class is defined to be the class you want viewWillAppear and viewDidAppear to be called in).

If you're not using IB, post your code for init/calling the viewController.

Jordan
Alright, cleaning up the IB entries seemed to do the trick. Good to know at least my approach was right.
Hauke