TabBar controller and Navigation Controller - who is the manager? - iphone

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.

Related

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.

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?
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.

IOS Storyboard when to use navigation controllers?

Hi I'm new IOS and have been using the storyboard feature, I followed this tutorial which resulted in a working app. I'm slightly confused when to use a navigation controller. In the tutorial above, every tab had a navigation controller. Is this necessary?
I'm in the process of creating a new app and it seems to work whether I add a navigation controller or not to each tab (see pic).
I'm just curios what is the correct process?
Thanks.
As your app is using a UITabBarController each tab will display a separate 'branch' of views. If any of these 'branches' needs its views to be wrapped in navigation functionality (or simply display the navigation bar with a title etc) then you would add a 'UINavigationController` as the primary view controller for that tab, in between the tab bar controller and the first view controller you wish to display for that tab.
If you want a tab to simply display a view controller which doesn't need hierarchical navigation or a navigation bar then you wouldn't need to use a UINavigationController and can directly set your view controller as the controller for that tab.

Problem in adding more than 5 button in tab bar controller in iphone

Hello everybody i need your help.
I am making a tab bar based application in iphone. i have more than 5 button to show in tab bar. when i did it, five button displayed fifth button is more..... but when i clicked on more then more button came in a table view not in tab bar.
That's how it works. From the documentation (http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/TabBarControllers/TabBarControllers.html%23//apple_ref/doc/uid/TP40007457-CH102-SW2):
If you add more than five items to the
viewControllers property, the tab bar
controller automatically inserts a
special view controller (called the
More view controller) to handle the
display of the additional items. The
More view controller provides a custom
interface that lists the additional
view controllers in a table, which can
expand to accommodate any number of
view controllers. The More view
controller cannot be customized or
selected and does not appear in any of
the view controller lists managed by
the tab bar controller. For the most
part, it appears automatically when it
is needed and is separate from your
custom content. You can get a
reference to it though by accessing
the moreNavigationController property
of UITabBarController.
That is intended behavior and not an issue, if you read the viewController Programming guide you could have seen that right away: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007457

Setting a tabbar view controller as a sub view of a nav controller

I guess I'm just really looking for some advice on how to approach my problem.
So far I have an application with a navigationcontroller that has a table view.
Every cell in the table has a text field and image and a disclosure button.
This is sort of my main menu option navigation screen.
When a user clicks a disclosure button I would like to go to a sub view of a tab view controller. The tab view will show different content depending on what cell is selected.
I'm guessing it would have something to do with the accessoryButtonTappedForRowWithIndexPath but after that I'm a little lost.
I've only ever experienced tab controllers from an example in a book where the tabbar controller was dragged onto a window in interface builder.
I'd like to try and pin down a direction to set to work to
I would highly recommend re-thinking your use of the tab bar here. The tab bar is intended to be a top-level control for navigating logically separate parts of your applications. Normal use would be tabs that contain navigation controllers that drill into detail within the navigation.
You may consider changing to use a toolbar rather than a tab bar. The toolbar is intended to change for the context of your current view. You can define the toolbar items in the view for the current navigation bar very easily.
All that said, if you are still set on using tab bar, I would keep the tab bar at the top level of your application and use setViewControllers:animated: to change the tabs when necessary. Again, I think this will end up producing a pretty confusing UI however.