Objective C: TabBarController and TableViewController - objective-c

i want a TabelView-Navigation and permanently a TabBar at the bottom .
I pushed the TabBarController. It contains a list of Controllers (ViewController, ... and the TableViewController)
But if i navigate down in the TableView the TabBar moves to the left outside the window (like the old Table).
How can i use the TabBarController without losing him?

The UITabBarController needs to be the root view controller. It sounds like you are pushing a UITabBarController onto the stack of a UINavigationController. What you want to do is make the UINavigationController one of the view controllers managed by the tab bar controller.

Do this.
Create the Tab Bar Controller and set it as your rootController.
//You will not have three tabs and you need three view controllers//
Set your First View controller as a Navigation View controller.
// You will now have the Navigation bar at the top//
Create a new file which is a subclass of the UITableViewController.
// set this as your delegate and datasource for your table view controller methods//
// pull a table view controller inside the Navigation View Controller as mentioned in (2) & you will have a tableview and navigation view in FirstViewController. Similarly work with the other two tabs
If you have any more doubts; please watch this tutorial on how to do all of these.
http://www.youtube.com/watch?v=LBnPfAtswgw

Related

Adding Navigation Item in UIViewController

I'm trying to add UINavigationItem to my UIViewController as mentioned this answer. However the Navigation bar is not showing in my view. I tried even adding an outlet and setting the title programmatically and also adding the NavigationItem in two different places. Still it doesn't show. This view controller is embedded in a TabBarController. WHat am I missing here?
Thanks is advance.
This view controller is embedded in a TabBarController
But is it embedded, first and foremost, in a UINavigationController? If not, there will be no navigation bar that automatically appears and that automatically uses your view controller's navigation item.
If you don't want to use a UINavigationController (because you have no navigation to do), then you can add a navigation bar manually. But in that case your view controller's navigation item will not be used automatically to populate the navigation bar; you must populate it manually.
Typically, people do use a UINavigationController, even if there is no navigation to do, just to get this automatic behavior - to show the navigation bar and to populate it automatically.
[NOTE: The fact that you have told Interface Builder to show a navigation bar for this view controller, as if it were in a navigation controller, is irrelevant; that won't cause you to get any navigation bar when the app runs.]

Show or Present ViewController?

I have an app in swift that starts with a rootViewController containing 3 buttons.
The first one should open a tabViewController with 3 tabs in it.
The second one should open a navViewController with a nested TableViewController that opens another tableViewController
The last one should open a regular view controller with 2 buttons, both opening a navController with a nested tableViewController
Which is the best "pattern" to use? should I use a ContainerViewController as root?
Which method is best to use for the main 3 buttons of the rootViewController to open the related controllers, the show or the present?
This is a sketch of my app: http://i60.tinypic.com/6jq537.png
The main thing to ask is how are these separate views related? And how are they related to the "menu" view at the beginning?
Tab View -
Nested Table View -
Another menu to two more tables...
First I'll go through how I would build each individually...
Tab View
I would probably create this in its own Storyboard. You don't specify if the tabs will have their own navigation in them? If so then each tab should start with a NavigationController. i.e. 1 tab bar controller with 3 tabs. 3 navigation controllers (one per tab) and then the root view controller of each navigation controller will be the content of the tab.
Nested Table View
The navigation of this should be handled in a navigation controller. So you either want to present a navigation controller with the first table view controller in it or you want to use a navigation controller to present it in the first place.
Third view
This is essentially a duplication of the menu view. Except each button goes to the Nested Table View mentioned above. Again, you will need a navigation controller.
What I would do
You probably should be starting with a Navigation Controller as your root view. If you want to get back to your menu view easily then that would make sense.
Then the issue of button 2 and 3 are trivial as you just push them onto the navigation controller.
For the tab bar controller I'd also push it onto the navigation controller but maybe think about hiding the navigation bar during the transition so as not to get caught up in which navigation controller is doing what.

Root view controller always set as tableViewController when Navigation Controller is set

When I use storyboards and drag out a navigation controller from the object library in Interface Builder, the root view controller, which comes with the nav controller, is always a table view controller.
Most of the time, I would just like a simple view controller. Is there a way to drag out the navigation controller and have a simple view controller set as the default, instead of the table view controller I'm getting now?
Thanks in advance!
The navigation controller usually comes connected to another controller which is the root controller. You can always delete the segue and table view controller, drag out a View Controller and reconnect the segue with a control click using the rootViewController option.

UIView controller containing toolbar and UITabBarController

I'm currently creating an ipad application.
the idea is to have a toolbar at the top and a tabbar at the bottom.
The toolbar has to be visible on all tabs, so it won't disappear.
I was thinking about having a UIViewController as the main view and put the tool bar in there.
Then adding the uitabbarcontroller to that main view controller, but i'm not sure how to do that.
At the moment i have my tabbarcontroller as the main view and added the toolbar to every tab.
Can anyone help?
Thanks
The Tab Bar Controller should be at the root. What you can do is create a method that returns a propertly configured toolbar & add it to each of the view controller's viewDidLoad (either by using a category method, inheriting a common UIViewController subclass, or simply via a C-style factory method.
This way your hierarchy isn't flipped, and the tab bar is at the root like it should be.

UINavgationController and UITabBarController together

I am trying to create a view with a TableView in the center, NavigationBar on top, and a TabBar with 5 items. The TabBarItems will be attached to 5 different modal views. And the tableview can select an item and "navigate" to another tableview or detail view.
Following the Apple doc, I tried to create a NavigationController in a TabBarController in IB, but failed. I read all the posting regarding to this topic, and they all described a NavigationController inside one of the TabBarItem. But that is not what I want. The TabBarController and NavigationController are separate controller doing separate thing in the same view.
So I start wondering maybe it is a design issue. I should just use a NavigationController and add the TabBar as objects and not controller in the view.
Am I going the right track or is there a better way to combine NavigationController and TabBarController in IB to do the job that I want. Am I making sense?
If the tab bar is actually being used as a tab bar, it sounds like you want 5 navigation controllers, one for each tab.
If the tab bar is being used as a toolbar to hold buttons that bring up modal view controllers, push views onto the navigation controller, or other actions besides what a tab bar is intended for, use a UIToolbar instead. UINavigationController actually has toolbar support built in, just set its toolbarHidden property to NO and set the toolbarItems property on each view controller that can go inside the navigation controller to an array of appropriate UIBarButtonItems.