简体   繁体   中英

Getting the current tab of a UITabBarController

I have a custom class called ATabBar that inherits from UITabBarController.

I have the following in my .m class:

- (void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    NSInteger tab = self.tabBarController.selectedIndex;
}

It appears that never gets hit in debugging. How do I grab when a tab is clicked in a function in my tab bar?

Managing the Selected Tab

selectedViewController (Property)

selectedIndex (Property)

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITabBarController_Class/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM