How to create a tabbar on clicking a row in table in iphone?

Posted by Warrior on Stack Overflow See other posts from Stack Overflow or by Warrior
Published on 2010-06-11T23:04:30Z Indexed on 2010/06/11 23:13 UTC
Read the original article Hit count: 188

Filed under:

My first view consist of table with 7 rows of data.When i click each row it should navigate to a view with tab bar with 4 tabitems .In this what is the proper approac of creating a tab bar. When should i create it.Should i create in didSelectRowAtIndexPath of the table in first view like this

UITabBarController *tabbar=[[UITabBarController alloc] init];
    Homepageview* vc1 = [[Homepageview alloc] initWithNibName:@"Homepageview" bundle:nil] ;

    vc1.tabBarItem.title=@"Home";
    vc1.tabBarItem.image = [UIImage imageNamed:@"home.png"];

    ShoppingView* vc2 = [[ShoppingView alloc] initWithNibName:@"ShoppingView" bundle:nil];

    vc2.tabBarItem.title=@"Shopping";
    vc2.tabBarItem.image = [UIImage imageNamed:@"shopping.png"];

    Checkout* vc3 = [[Checkout alloc] initWithNibName:@"Checkout" bundle:nil] ;

    vc3.tabBarItem.title=@"Checkout";
    vc3.tabBarItem.image = [UIImage imageNamed:@"checkout1.png"];


    Settings *vc4=[[SlSettings alloc] initWithNibName:@"Settings" bundle:nil] ;

    vc4.tabBarItem.title=@"Settings";
    vc4.tabBarItem.image = [UIImage imageNamed:@"setting1.png"];

    tabbar.delegate = self;
    tabbar.viewControllers = [NSArray arrayWithObjects:vc1, vc2, vc3,vc4,nil];
    //self.navigationItem.title=@"Snhopping list";

    //[tabbar.selectedViewController viewDidAppear:YES];        

    [self.navigationController pushViewController:tabbar animated:YES];
     [vc1 release];
     [vc2 release];
     [vc3 release];
     [vc4 release];
     [tabbar release];

Or is there any alternate to do it. If i do it by the above method , when i navigate from the home page view of tabbar to another view then i am not able to get tab bar.Please help me out.Thanks.

© Stack Overflow or respective owner

Related posts about iphone