Programmatically Setting UITabBar Titles

前端 未结 2 757
盖世英雄少女心
盖世英雄少女心 2021-01-16 06:41

i had programetically add the tabbar as shown below:-

FirstViewController *obj_FirstViewController = [[FirstViewController alloc] initWithNibName:@\"FirstVie         


        
2条回答
  •  再見小時候
    2021-01-16 06:59

    Pls Try this

    FirstViewController *obj_FirstViewController = [[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:nil]; 
    SecondViewController *obj_SecondViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; 
    ThirdViewController *obj_ThirdViewController = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
    
    navigation1 = [[UINavigationController alloc] initWithRootViewController:obj_FirstViewController];  
    navigation2 = [[UINavigationController alloc] initWithRootViewController:obj_SecondViewController];
    navigation3 = [[UINavigationController alloc] initWithRootViewController:obj_ThirdViewController];
    
    navigation1.title=@"Home";
    navigation2.title=@"Second";
    
     MainTabBar = [[UITabBarController alloc] init];
    MainTabBar.delegate=self;
    [MainTabBar setViewControllers:[NSArray   arrayWithObjects:navigation1,navigation2,navigation3,nil]];
     MainTabBar.view.frame=self.view.frame;
     MainTabBar.selectedIndex=0;
    [self.view addSubview:MainTabBar.view]
    

提交回复
热议问题