0

Good morning, I'm trying to hide a UITabBarItem and after read lots of posts here, I'm getting crazy....I can get the tabItem properly, but it doesn't hides. I setup my TabBar in Storyboard.

Here is my code..none of the 3 options I tried works...

Any helps will be appreciated

@implementation unidaAppDelegate

@synthesize window = _window;
@synthesize tabBarController = _tabBarController;


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
    self.tabBarController = [storyboard instantiateViewControllerWithIdentifier:@"myTab"];

    NSMutableArray *tabs = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
    NSLog(@"Array:%@",tabs);


    /*
    OPTION 1

    NSMutableArray *viewControllersCopy = [[self.tabBarController viewControllers] mutableCopy];
    [viewControllersCopy removeObjectAtIndex:2];
    NSArray *modifiedViewControllers = [[NSArray alloc] initWithArray:viewControllersCopy];
    [self.tabBarController setViewControllers:modifiedViewControllers animated:NO];

    OPTION 2

    NSMutableArray *modifyMe = [[self.tabBarController.tabBar items] mutableCopy];
    [modifyMe removeObjectAtIndex:2];
    NSArray *newItems = [[NSArray alloc] initWithArray:modifyMe];
    [self.tabBarController.tabBar setItems:newItems animated:true];


    OPTION 3

    NSLog(@"TabBarItem: %@",[[self.tabBarController.tabBar.items objectAtIndex:2] title]);
    [[self.tabBarController.tabBar.items objectAtIndex:2] setEnabled:FALSE];
     */

    sleep(1); 
    return YES;
}
Alladinian
  • 34,483
  • 6
  • 89
  • 91
Christian
  • 382
  • 2
  • 11

1 Answers1

0

if you are using xcode 4.x try to do it by selecting the UIviews you want to embed in a tabBarController and the go to Editor>Embed in> Tab Bar Controller. I do it this way and it works better.