viewWillAppear in viewcontrollers of a tabbar

niklassaers picture niklassaers · Jul 17, 2010 · Viewed 7.5k times · Source

In my tab-bar I have four viewcontrollers, and what happens in one can affect the view of the other, so I may need to reload some elements in the viewcontroller when it becomes visible. Normally I'd fix that by implementing viewWillAppear, but when I switch between the tabs, viewWillAppear does not seem to get called. How can I fix that, or what should I do instead?

Update: as a PS I should add that this is a tabbarcontroller in a navigationcontroller hierarchy

Cheers

Nik

Answer

Radix picture Radix · Jun 13, 2012

You may use the tabbar controller delegate works like a charm

-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    [viewController viewWillAppear:YES];

}