No top navigation bar in a tab bar controller application - iphone

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?

If you want to show a navigation bar on two ViewControllers of your tab bar based application, then you can do as follows:
Delete the viewcontroller1, then drag ViewController into storyboard from library and select it and go to Editor\Embed In\Navigation Controller.
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!

follow as Nuzhat Zari to show navigation bar on viewcontrollers of your tabBar based application

self.tabBar.frame =CGRectMake(0,0,self.view.frame.size.width,50);
This will make Tab Bar to appear at the top of controller.

Related

Is there a way to show UINavigationController in the second storyboard if that UINavigationController in the first storyboard?

I have the first storyboard has UINavigationController its continues to the second storyboard but it doesn't appear there only when running the app.
I link between storyboard by (Storyboard Reference)
The first storyboard
The second storyboard
The UINavigationController doesn't appear in the second storyboard its appear only when running the app.
according to navigation controllers property it will not show the navigation bar in your case , if you want to edit or customise navigation items or navigationbar then you have to make changes programatically .
but to make changes in navigationbar or navigation items there is some limitations sometimes you can't fully customise it and sometimes you customise it depend on your requirement ... :(
I suggest you that use navigation property but hide the navigation bar
and on place of navigation bar (on top of every view controller) set a
view which will look like navigation bar and you can easily customise
it as per your requirement .
This is normal behaviour of the Storyboard as the controller in your second storyboard does not know if it is a controller in a navigation controller, hence it does not show the navigation bar. If yo want to show the navigation bar in the storyboard you can select it in the Simulated Metrics in the Attributes Inspector (shown here in that thread). You can see it working by giving the controller a title for example.

How to drag a navigation controller into a tab bar controller within a storyboard?

With xibs if you wanted to combine a navigation controller and tab bar controller you could just drag n drop the navigation controller into the tab bar controller.
However this is not possible now with storyboards (in Xcode 5). Is there some other way of doing it graphically?
Note I don't want the navigation controller to cause a tab to appear in the tab bar controller as will happen if you ctrl drag from the tab bar controller to the nag controller. I want a navigation bar and tab bar combined in one view.
There's dozens and dozens of tutorials for this out there, but they are all using nibs or old versions of storyboards/xcode, and when I try to do it for Xcode 5 it isn't possible. I was wondering if there's some new trick to get the same behavior as was previously possible.
In a storyboard, you can control-drag or right-click drag from the UITabBarController to the UINavigationController to add it as one of the view controllers for the tab bar.

Navigation Bar is displaying at the bottom

as you can see from the picture i have added, my navigation bar is displaying at the bottom of the screen under my table view. I have just dragged and dropped my navigation bar on to that view controller which means i'm not using a navigation controller. I don't understand why this is happening and i'm sure its a simple fix which i am missing.
image 2 is the storyboard view
image 3 view of the app running
Any help is much appreciated, Thanks!
Delete your old navigation bar
Select your TableViewController and on top click editor->Embed in-> Navigation Controller
Now you should have a navigation bar on top.
See screenshot. You dragged a navigation bar into your table. To achieve the behavior you want you can embed your view controller inside a UINavigationController and access your navigation bar via self.navigationController.navigationBar.
I got your problem
What you have done is you have taken your navigation bar inside tableview...
that is the problem..
you just dragged that navigation bar outside that tableview...and that's it..

iphone sdk: How do i hide the tabBar in my UITabBarController?

My application consists out of a tabbarcontroller and inside i got multiple navigationControllers. Now i want to hide the bottom bar of the tabbarcontroller from the start because the buttons on the bottom bar lead to features inside the application which are just not ready yet so i dont't want the user to see them. How do i do this?
Thanks in advance!
A couple of options:
Set hidesBottomBarWhenPushed=YES on one of the controllers in your navigation controller. I'm not sure if this works on the root view controller of a navigation controller.
Hide the tab bar items by changing UITabBarController.viewControllers. I'm not sure if it lets you have a tab bar with only one tab, but it ought to.
Set the tab bar controller's delegate (see UITabBarControllerDelegate). In – tabBarController:shouldSelectViewController:, return NO if it hasn't been implemented yet.

TabBar controller and Navigation Controller - who is the manager?

I would like to have a view (Hierarchy structure) under Navigation Controller (the top blue navigation bar) that has a TabBar (the black one in the bottom part) to show additional views (each for tab) at the same level.
If you select one of theese views (black tab bar) you should always have the TabBar visible to jump to another view of the same level. In case you want to go back to the upper hyerarchical level you have to select the "back" navigation button in the top bar (blue one) and the "tab bar" should disappear.
Why Apple suggests (it seems to me) to avoid that ?
I'm quoting from "View Controller Programming Guide for iPhone OS" page 39 where is written:
It’s very common to combine tab bar and navigation controllers, as illustrated in Figure 4. To do this, you simply add navigation controllers to a tab bar controller (however, you should never add a tab bar controller to a navigation controller).
Instead I would add a "Tab Bar" under a "Navigation bar" (the manager)
Do I think wrong ?
Thanks for your help !
Dario
What they mean is that a tab bar should never be the child of a navigation view. The tab bar is really meant to define different "modes" of your application, while navigation controller's are to show hierarchal data.
If you want some kind of mode within a navigation controller, I think a toolbar tends to be used. For example the toolbar at the bottom in the Mail app.
UIToolbar Docs
The following is correct according to what I have managed to dig on severals forums and documentations:
Tab Bar Controller > Navigation Controller > View
You do a lot just with the interface builder and then bind the TabBarItems, NavigationItems and Controllers to outlets in your code.
Some doc samples:
Building an iPhone App Combining Tab Bar, Navigation and Tab (YouTube)
iphonedevsdk (Forum)
Add NavigationController to TabBarController (Forum Tutorial)
Good luck, you can't do much if you stick to documentation. Visit forums and look for videos.
What they mean is that navigation controller should never get pushed a tab bar view controller because it cannot support it, however a tabbarviewcontroller can support a navigation view controller so you can do it like that. You can also just add a tab bar to your navigation view controllers view (not the navigation stack) and have the navigation view manage the tab bar instead of the UITabBarViewController.