detect when a tabBar item is pressed via UITabBarController from App Delegate

Viewed 9035

I know this question has been asked a few times, but I am still stuck on the case when I have my UITabBarController in my AppDelegate class and viewControllers are set there only as

self.tabBarController.viewControllers = 
     @[aboutUsNavController,myProfileNavController,
      projectsListNavController, feedsNavController,homeViewController];

Now what I want is to perform a task at the tap of TabBar item feedsNavController not in viewWillAppear (because it is pushing a detailView via navigationController ).

I have set delegate in the same class to perform a UITabBarController delegate method:

 AppDelegate *appDelegate = 
         (AppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.tabBarController.delegate = self;

But -(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController only works when I switch the TabBar Item, but not at the first time?

Is there any way I can call UITabBarDelegate instead:

-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item

in order to get the reference when tabBar item is pressed?

Or any other approach would be appreciated.

3 Answers
Related