Adding a UITabBar Programmatically?

Discussion in 'iOS Programming' started by Blakeasd, Jun 17, 2011.

  1. Blakeasd macrumors 6502a

    Joined:
    Dec 29, 2009
    #1
    Hello,
    I am developing a Mac application with the Chameleon framework, which is a port of UIKit to the Mac, so I am posting this in the IOS programming section.
    Anyway, I am trying to add a UITabBar to my application, but I can't get it to work. I do not get any errors or warnings, the problem is the UITabBarItem I created doesn't appear. Here is my code:
    Code:
    
    -(void)applicationDidFinishLaunching:(UIApplication *)application{
    
    
        window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
        window.backgroundColor = [UIColor clearColor];
        window.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [window makeKeyAndVisible];
        
        
        tabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, 0, 1057, 64)];
        [siteItem setImage:[UIImage imageNamed:@"Cloud.png"]];
        [siteItem setEnabled:YES];
        [siteItem setTitle:@"Sites"];
        [siteItem setTag:1];
        [tabItemsArray addObject:siteItem];
        [tabBar setItems:tabItemsArray];
        [window addSubview:tabBar];
        
        
    }
    
    
    What's wrong with my code? I know there will be some differences between Chameleon and UIKit so I apologize.
    Please Help
    Thanks
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    How is siteItem defined? Where is it initialized? Same questions for tabItemsArray.
     

Share This Page