iPhone SDK: Know when tab on Tab Bar is clicked?
-
26-09-2019 - |
Question
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)
Solution
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
OTHER TIPS
I would use - (void)viewWillAppear:(BOOL)animated
in UIViewController (docs)