I was just wondering how I can hide the tab item in the Tab Bar Controller
for the current view controller which is selected
Asked
Active
Viewed 1,079 times
0
-
How can you select other tabs when its hidden in current view??? – Paresh Navadiya Apr 14 '15 at 12:44
-
Are you working in Swift or ObjC? – Wez Apr 14 '15 at 12:47
-
@Wezly Working in ObjC – Bobby W Apr 14 '15 at 12:49
3 Answers
3
Remove intended index from controllersArray ex. (1)
NSMutableArray *controllersArray = [NSMutableArray arrayWithArray:self.tabBar.viewControllers];
[controllersArray removeObjectAtIndex: 1];
[self.tabBar setViewControllers:controllers animated:YES];
Check for this answer also I found this similar from your question Hide tab bar item and aligning other tab items Hope this helps you.!!

Community
- 1
- 1

Jemythehigh
- 583
- 5
- 12
1
Firstly, I don't think it's possible to hide a UITabBarItem
- It inherits from UIBarItem
but there is no hidden
property - UIBarItem Documentation
You could try comparing the tab bars selectedViewController
property against your current view controller? - Something like below might work..
if (self.tabBarController.selectedViewController == self) {
// Do Stuff
}
But even then I think you are going to find it hard to hide the tab bar item itself.

Wez
- 10,555
- 5
- 49
- 63
-
1Yeah, after reading some more. I figured the best solution for my situation, is to remove it completely, once done with that view controller. i.e. the login screen. – Bobby W Apr 14 '15 at 13:13
0
UIView *parent = self.tabBarController.tabBar.superview; // UILayoutContainerView
UIView *content = [parent.subviews objectAtIndex:0]; // UITransitionView
UIView *window = parent.superview;
[UIView animateWithDuration:0.2
animations:^{
CGRect tabFrame = self.tabBarController.tabBar.frame;
tabFrame.origin.y = CGRectGetMaxY(window.bounds);
self.tabBarController.tabBar.frame = tabFrame;
content.frame = window.bounds;
}];

Rahul Mayani
- 3,761
- 4
- 25
- 40