Hi I'm trying to add and remove tab bar items dynamically. There are two arrays. First, the first added tabbaritem named Advanced is shown, and another array is added to the tab when the user clicks Advanced. The user can return to the first array by clicking Less tabbaritem in the second array. The problem is that when I often click the “More” and “less” tabbaritems in the sequences “More”, “Less”, “More”, “Less”, “Less”, “Less”. It seems to me that it seems to me that this is a cool class, and therefore this is a tab controller. I can not understand the problem. Below is the code for the delegation method of the tab bar.
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { NSLog(@"selected view controller is :%@",viewController); if(viewController.view.tag == -1){ [self.tabBarController setViewControllers:self.level2TabBarItems animated:YES]; [self.tabBarController setSelectedIndex:0]; }else if(viewController.view.tag == -2){ [self.tabBarController setViewControllers:self.level1TabBarItems animated:YES]; [self.tabBarController setSelectedIndex:0]; }
}
Can someone please tell me where I am doing wrong? Best wishes
source share