开发者

Listening for TabBar view change

开发者 https://www.devze.com 2023-03-13 23:06 出处:网络
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 alter

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 {...}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号