views:

83

answers:

2

I have a tab bar which displays different views when clicked. When you click a tab for the first time, it calls the viewDidLoad method. But, it only calls that the first time.

Is there a method that is called when a user clicks back to that tab, since the viewDidLoad won't be called that second time?

(I need to do this to update a UITableView when the user clicks back to a tab)

A: 

I would use - (void)viewWillAppear:(BOOL)animated in UIViewController (docs)

cobbal
It's better to use the UITabBarController delegate methods. If the tab contains a UINavigationController the viewWillAppear might be undesirable because it will also be called when controllers are popped of the navigation controller
nduplessis
+2  A: 

Of course!

- (void)tabBarController:(UITabBarController *)aTabBarController didSelectViewController:(UIViewController *)viewController

Your best option when looking for these sorts of things is to look in the documentation, specifically at the delegate for the object you're interested in. http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITabBarControllerDelegate_Protocol/Reference/Reference.html

alku83