views:

385

answers:

3
+1  Q: 

Tab bar navigation

Hi, I have made an application in which I have four tab bars. I have used the below code to go to the second view in a button's click method. It goes to the second view but the second view is not showing with tab bars. How can I fix this?

- (IBAction)Existinguser:(id)sender
{
   ExistingUserViewController *existingUserViewController = 
       [[ExistingUserViewController alloc] 
             initWithNibName:@"ExistingUserViewController" bundle:nil];

   [self presentModalViewController:existingUserViewController animated:YES];
   [existingUserViewController release];
}
A: 

Presenting a view controller modally will show that view controller above all ther other UI elements (this includes the navigation bar and tab bar, but not the status bar).

If you want to show your "second view" as the view on the second tab, then you need to set the view controller you want to use as the second tab's view controller. That way when you press the second tab, the second view controller will be shown, and the second tab will be selected and visible.

Jasarien
i have a view-based application.
A: 

I might be mistaken, but do you have a single tab bar with four tabs and you are looking for a way to change to the second tab? You can do this with the following code:

    self.tabBarController.selectedIndex = 1;

btw the code you attached to your question is displaying a new model view controller above the current view controller. This is the reason no tabbar is shown.

Markus Müller
A: 

If you are trying to create a navigation based app using tabbar, in IB, change the tab's viewcontroller to UINavigationController. You can then use the UINavController methods to navigate between views. In case you don't want to show the navbar, just set that property in IB.

Here's a good example of how you can use tab bar with navbar

lostInTransit
i hav view-based app, in which i hav 4 tabbars in 1st tabbari hav a button on button click i m showing another view wd above code i posted, it is showing another view but nt showing tabbar, i need tabbar in this view 2. is m i missing something to mention in appdelegate or 1st view. tell me where m wrong
If you want a tabbar to show up on all screen,s consider using Tab-based application instead of a view-based app.
lostInTransit