How do I hide an individual tab bar button ?
I've searched and not found anything, only the full bar.
I've made some progress but still having problems, this code is in my app delegate with an outlet to the tab bar, I'm calling it within viewDidLoad
of the first view shown in tab bar.
-(void)hideTabButton {
NSMutableArray *aItems = [[rootTabBar items] mutableCopy];
for (UITabBarItem *tabButton in aItems) {
if ([tabButton.title isEqualToString:@"First"]) {
[aItems removeObject:tabButton];
break;
}
}
[rootTabBar setItems:aItems animated:YES];
[aItems release];
}
But this gives me an error, it does seem to be possible otherwise why have setItems
.
Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'Directly modifying a tab bar managed by a tab bar controller is
not allowed.'
Call stack at first throw:
Heres my full code, think I'm close. My Sample project