Tab bar in view based application?

前端 未结 1 1228
星月不相逢
星月不相逢 2021-01-16 09:54

I am new to iphone development.I have created a view based application.Now i want tab bar in that view.The first view of the tab bar is a table view and the second view is t

相关标签:
1条回答
  • 2021-01-16 10:46

    Try this one. This code for created a tab bar application in programmatically. So clicked the button it will open the tab bar in the view.

       -(IBAction) clkBtn:(id) sender
       { 
    
        UITabBarController *tabbar1 = [[UITabBarController alloc] init];
    
        firstViewController  *first = [[firstViewController alloc] initWithNibName:@"firstViewController" bundle:nil];
    
        UINavigationController *tabItem1 = [[[UINavigationController alloc] initWithRootViewController: first] autorelease];
    
        secondViewController  *second = [[secondViewController alloc] initWithNibName:@"secondViewController" bundle:nil];
    
        UINavigationController *tabItem2 = [[[UINavigationController alloc] initWithRootViewController: second] autorelease];
    
        tabbar1.viewControllers = [NSArray arrayWithObjects:tabItem1, tabItem2,nil]; 
    
        [self.view insertSubview:tabbar1.view belowSubview: first.view];
    
        [self presentModalViewController:tabbar1 animated:YES];
    
      }
    

    Thanks,

    Best of Luck.

    0 讨论(0)
提交回复
热议问题