iphone app - detect which tab bar item was pressed

后端 未结 7 1126
我寻月下人不归
我寻月下人不归 2020-12-10 02:16

i have a tab bar based application, with more than 5 tab bar items - so i get 4 of them directly showing in the view and the rest available by selecting the \"More\" tab. Wh

7条回答
  •  独厮守ぢ
    2020-12-10 02:37

    - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
    {
    
     NSLog(@"Selected index: %d", tabBarController.selectedIndex);
    
    if (viewController == tabBarController.moreNavigationController)
    {
        tabBarController.moreNavigationController.delegate = self;
    }
    
    NSUInteger selectedIndex = tabBarController.selectedIndex;
    
    switch (selectedIndex) {
    
        case 0:
            NSLog(@"click tabitem %u",self.tabBarController.selectedIndex);
            break;
        case 1:
            NSLog(@"click me again!! %u",self.tabBarController.selectedIndex);
            break;
    
        default:
            break;
    
    }
    
    }
    

提交回复
热议问题