Listening for TabBar view change
I need to know evertime a certain tab on my tabbar is selected to be able to set a certain BOOL
. viewDidLoad
does net get called every time/when I click on the tab - i开发者_如何学编程s there an alternative to that?
I need to know this in that tab's-view's viewcontroller.
You probably want one of these:
The UITabBarDelegate method
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
The UITabBarControllerDelegate method
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
The UITabBar does not load all the view controllers at once - it loads the first one. When you click on a tab bar button you load another controller.
To receive the changes in the tab bar you can add a delegate and implement:
-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {...}
精彩评论