Wednesday, 22 January 2014

Tabbar Controller

//AppDelegate.m

UIViewController *viewcontroller=[[UIViewController alloc]initWithNibName:@"firstViewController" bundle:nil];
    UITabBarController *tab=[[UITabBarController alloc]init];
    UITabBarItem *tab1=[[UITabBarItem alloc]initWithTitle:@"welcome" image:[UIImage imageNamed:@"dummy_album_art.png"] tag:0];
    UIViewController *view1=[[UIViewController alloc]initWithNibName:@"thirdViewController" bundle:nil];
    UITabBarItem *tab2=[[UITabBarItem alloc]initWithTitle:@"bye" image:[UIImage imageNamed:@"led_off.png"] tag:1];
    [view1 setTabBarItem:tab2];
    [viewcontroller setTabBarItem:tab1];
    UIViewController *second=[[UIViewController alloc]initWithNibName:@"secondViewController" bundle:nil];
    UITabBarItem *tab3=[[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemContacts tag:0];
    [second setTabBarItem:tab3];
    UIViewController *fourth=[[UIViewController alloc]initWithNibName:@"fourthViewController" bundle:nil];
    UITabBarItem *tab4=[[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:0];
    [fourth setTabBarItem:tab4];

    tab.viewControllers=@[viewcontroller,view1,second,fourth];

    self.window.rootViewController=tab;

No comments:

Post a Comment