Add Uitabbarcontroller without storyboard

Asked

Viewed 48 times

0

How do I add a Uitabbarcontroller with Uinavigationcontroller, but I would like to add in a second view, because I have the login start screen and I would not like to display the tabbar in that first view, I found some examples but they all added these controls in Appdelegate and someone would know how to do that?

1 answer

1

    UITabBar *suaTabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
    suaTabBar.delegate=self;
    [self.view addSubview:suaTabBar];
  • Thanks friend thanks, this is the correct way to add without using storyboard?

  • Yes! With this code snippet, you will manually create a Tabbar, without needing a Storyboard.

  • I can add one Uinavigationcontroller normally in this case?

  • Yes, no problem, in that case you will have to put this snippet also in your Navigationcontroller.

  • 1

    Wrong Leonardo, you don’t start Navigation and then Tabbar... The correct is to initialize Tabbar and for each viewcontroller it contains, you allot a Navigationcontroller or a normal View (in the example I give a set in the viewcontrollers set) Example: Aviuingationcontroller *navSearch =[[UINavigationController alloc] initWithRootViewController:[[BCCSearchViewController alloc] init]];
 [self.tabBarController setViewControllers:@[navSearch]];
 [navSearch.tabBarItem setImage:[UIImage imageNamed:@"tab-pesquisa"]];
 [navAnuncie setTitle:@"Anuncie"];

  • You would have some example of how I can implement this?

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.