Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide tab bar item and aligning other tab items

In my app, i have 4 tab bar items. Iam adding these 4 tab bar items in XIB file.

Initially i have to show 3 tab bar items and after sync i have to show 4th tab bar item in my app. So for this, i am hiding 4th Tab bar item using following code.

[[[self.tabBarController.tabBar subviews] objectAtIndex:03 setHidden:YES];

The tab item is hiding but i am having blank space in place of the hidden item. Is there any chance to align other 3 items in full tab bar. The thing is i dont want to show blank space or empty space in tab bar.

Thanks Jithen

like image 806
Coder Avatar asked Apr 13 '13 08:04

Coder


1 Answers

If you want to get the items of the tabBar rearranged you have to remove the controller from the controllers list, not hide it. You can use this code to achieve this:

NSMutableArray *controllers = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
[controllers removeObjectAtIndex:3];
[self.tabBarController setViewControllers:controllers animated:YES];
like image 146
tkanzakic Avatar answered Sep 28 '22 07:09

tkanzakic