I have two tab bars in order to have effect like the one shown in Question of Sliding UITabBarItems in UITabBarController
Instead of an arrow, I am trying to use tab bar item at last index to show another tab bar, and hiding the current tab bar. I am adding second tab bar programmatically in viewDidLoad
. Problem is that my second tab bar is not showing up on when last tab bar item is tapped. What I have done is:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.tabControler.view.frame = self.view.frame;
self.tabControler.delegate = self;
self.secondTabBarSelected = NO;
self.secondTabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, 431, 320, 49)];
self.secondTabBar.hidden = YES;
self.secondTabBar.delegate = self;
self.secondTabBar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
[self.tabControler.view addSubview:secondTabBar];
[self.view addSubview:tabControler.view];
NSLog(@"children of tabcon: %@",[tabControler.view subviews]); //Here second tab bar added with correct frame
}
-(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if (!self.secondTabBarSelected) {
NSLog(@"first tab bar");
if([[tabBarController viewControllers] indexOfObject:viewController] == 3)
{
self.firstTabBar.hidden = YES;
self.secondTabBar.hidden = NO;
}
}
}