Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No top navigation bar in a tab bar controller application

I'm pretty new in iphone programming and have stumbled upon this issue which I guess should be pretty basic stuff.

I am using a tab bar application created from a template in XCode IOS 5.1. It works fine and creates 3 screens in the storyboard (tab bar controller + + 2 descended views) but when I try adding a top bar to these 2 views there is a problem...

I do this by adding the top navigation bar in interface builder from object inspector for the tab bar controller. After ticking this option the top bar shows perfectly in my storyboard for all 3 screens (tabbarcontroller + 2 descended views) but after I run the project the top navigation bar is no longer there.

What am I missing here? Why is there no top bar?

like image 208
user1454623 Avatar asked Jun 18 '12 13:06

user1454623


People also ask

How do I add a tab bar to my navigation controller?

To add a tab, first drag a new View Controller object to the storybard. Next control-drag from the tab bar controller to new view controller and select view controllers under Relationship Segue . Your tab bar controller will update with a new tab.

What is a tab navigation bar?

A tab bar lets people navigate among different areas of an app, like the Alarm, Stopwatch, and Timer tabs in the Clock app. If you need to provide controls that act on elements in the current view, use a toolbar instead. Make sure the tab bar is visible when people navigate to different areas in your app.

What is a tab controller?

They allow a user of to switch between multiple arbitrary view controllers by maintaining an array of UIViewControllers . They can be used to allow the user to navigate between entirely different parts of your application, or they can be used to display two different views of the same backing data.

How do you hide the tab bar when a view controller is shown?

If you don't want that behavior, you should set hidesBottomBarWhenPushed to true where applicable. This will hide the tab bar along with any toolbars you had showing, but only when a view controller is pushed onto the navigation stack. This allows you to show the tab bar at first, then hide it when you need more room.


1 Answers

If you want to show a navigation bar on two ViewControllers of your tab bar based application, then you can do as follows:

  1. Delete the viewcontroller1, then drag ViewController into storyboard from library and select it and go to Editor\Embed In\Navigation Controller.

  2. From the UITabBarController, click on tabbar and right click, select relationship and drag it to the navigation controller. (means add the UINavigationController as a tab).

Hope this helps!

like image 192
Nuzhat Zari Avatar answered Oct 02 '22 12:10

Nuzhat Zari