Instagram like tab bar

Discussion in 'iOS Programming' started by ljg93, Feb 25, 2012.

  1. ljg93 macrumors member

    Mar 13, 2011
    Hey everyone,

    I followed this tutorial on how to make a tab bar like the one on instagram (

    I have it functioning inside my app but, I am having trouble getting the tabs to go to certain view controllers and the tab bar to actually work like a tab bar.
    Right now, the tab bar just appears on the screen with a black background. (Attached is a screenshot)

    if you download the project and go into the baseviewcontroller.m you will see the following code

    -(UIViewController*) viewControllerWithTabTitle:(NSString*) title image:(UIImage*)image
      UIViewController* viewController = [[[UIViewController alloc] init] autorelease];
      viewController.tabBarItem = [[[UITabBarItem alloc] initWithTitle:title image:image tag:0] autorelease];
      return viewController;
    Which I believe sets the tab bar up for the code in the instagramViewController.m
     self.viewControllers = [NSArray arrayWithObjects:
                                [self viewControllerWithTabTitle:@"Feed" image:[UIImage imageNamed:@"112-group.png"]],
                                [self viewControllerWithTabTitle:@"Popular" image:[UIImage imageNamed:@"29-heart.png"]],
                                [self viewControllerWithTabTitle:@"Share" image:nil],
                                [self viewControllerWithTabTitle:@"News" image:[UIImage imageNamed:@"news.png"]],
                                [self viewControllerWithTabTitle:@"@user" image:[UIImage imageNamed:@"123-id-card.png"]], nil];
    I am pretty sure I need to replace it with code like this
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
        // Override point for customization after application launch.
        UIViewController *viewController1, *viewController2;
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
            viewController1 = [[[FirstViewController alloc] initWithNibName:@"FirstViewController_iPhone" bundle:nil] autorelease];
            viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController_iPhone" bundle:nil] autorelease];
        self.tabBarController = [[[UITabBarController alloc] init] autorelease];
        self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
        self.window.rootViewController = self.tabBarController;
        [self.window makeKeyAndVisible];
        return YES;
    Am I on the right track? Any suggestions?

    Attached Files:

Share This Page