问题
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
回答1:
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];
来源:https://stackoverflow.com/questions/15985869/hide-tab-bar-item-and-aligning-other-tab-items