Search code examples
iosuitabbar

Check if TabBar Item has been selected


I'm new in iOS programming, I'm wondering if there is a way to use TabBar inside normal view instead of UITabBarController.

This is my scenario:

I've a UIViewController with a TabBar and a Container. Container is embedded to a UIPageViewController to show different pages. I made this due to easy way to control layout in storyboard. The problem is that I don't know how to use tabBarController:didSelectViewController: function with this setup. I'm able to use it in normal UITabBarController but I want to force my custom view to works! This is my setup: Storyboard Setup

Is there a way to catch a tab item selected action with this setup?


Solution

  • I found the solution. It was so simple! Just setted self.myTabBar.delegate = self; and <UITabBarDelegate> and using -(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item instead of tabBarController's one.