I'm trying to figure out how to catch the event that controls the switch tabs on the UITabBarController
. How could I accomplish this?
The tab bar always appears across the bottom edge of the screen. A UITabBar object contains one or more UITabBarItem objects. However, we can customize the appearance of the Tab Bar by changing its background color, image, or tint color according to the interface.
With the Landscape Tab Bar feature enabled, Safari automatically displays the open tabs along the top of the screen when you use your iPhone in landscape orientation. Now, to switch between open tabs, all you need to do is swipe through them horizontally or tap the tab you wish to use.
Implement UITabBarControllerDelegate
e.g. in your app delegate's applicationDidFinishLaunching
- (void)applicationDidFinishLaunching:(UIApplication *)application { tabBarController.delegate = self; [window addSubview:tabBarController.view]; }
Then implement either:
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController; - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController;
The first method is called before the view switch and gives you a chance to 'veto' the view switch by returning NO
The second method is called after the view switch has taken place
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With