Reputation: 517
I have TabBar
application. When I launch app I have all tabs color gray (not selected). In launch(first) tab show last news. When I click first tab it show search (below method is called). In other tabs I have button "Home". When I click this button I show first tab with news and set gray color for first tab. If I click again first tab it not show search. I need how to check if user click the first tab again.
I have UITabBarControllerDelegate
and self.tabBarController.delegate = self;
I have this method but it does not work.
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
}
Method for home:
-(void)home
{
self.tabBarController.selectedIndex = 0;
}
Upvotes: 1
Views: 404
Reputation: 11201
If you use the Tab Bar Controller template in xcode, which has a Tab Br Controller with two Tabs.
You have to create a .h and .m file for the Tab Bar and in sotryboard you have to give this file as the file owner for your tab bar controller and in the tabBAr.m file, you need to use the following method:
-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{
//handle your selection here. THis gets called everytime you select a tab item
}
Upvotes: 1