Show or Present ViewController? - objective-c

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.

Related

UIStoryBoard Navigation Controller disappearing after segue

Reference layout via storyboard:
http://i.imgur.com/M7AmdP2.png
Reference landing page:
http://i.imgur.com/Y3g45uy.png
I am trying to use the bottom bar as displayed in picture 2 to control my app. When I select my option on the first page (Such as the songs tab), but when I go to the next page my navigation bar at the bottom disappears. I am using segues to direct my applications view flow.
I have tried making various controllers subclassed to a UITabBarController & pushing as modal. Neither of those kept the navigation controller
You shouldn't have that navigation controller as the initial controller, the tab bar controller should be first. Then, in each of the three tabs, the root view controller should be a navigation controller, followed by the ones you show in your image.

Storyboard with NavigationController and TabController

It seems like this should be easy to figure out, but I haven't had any luck this afternoon. I threw together this quick, simplified storyboard mockup of my problem.
Basically, I would like the table view controllers below to also be in a tab bar controller (in addition to the already present navigation controller). The tabs would switch between the two table view controllers.
Right now, the view controller with the buttons acts as a sort of menu. Each button leads to one of the table view controllers. Ideally this view controller would not have the tab bar visible, and would only be reachable from back buttons on the nav bars of the table view controllers.
I've tried a few different ways of embedding into a tabbarcontrollers but none of them produce the desired result:
-I've tried selecting both table view controllers and embedding those in a tab view controller. The tabbar doesnt show up in simulator, and the 'unreachable scene' warning appears.
-I've tried embedding the initial nav controller into a tabbarcontroller. This creates a tab entry for the first 'menu' page. It also causes issues with push segues once I connect the tableviews to the tabview.
I would be fine implementing some programmatic options on top of the storyboard, I just chose storyboarding for this project since it's a relatively simple presentation of data.
What is the proper way of going about this? Thanks!
A tab bar controller needs to be the root view controller of your view hierarchy. It goes against the HIG and Apple's standards to put a tab bar controller inside of any other type of container controller.
From the Apple docs:
When deploying a tab bar interface, you must install this view as the
root of your window. Unlike other view controllers, a tab bar
interface should never be installed as a child of another view
controller.
So, the bottom line here is you need to rethink your design. One option would be to set the UITabBarController as the root view of your window, and then have each of your UITableViewControllers inside of a UINavigationController, which is placed inside of the UITabBarController. In this way, you still get the navigation bar, and stay within Apple's design guidelines (you also won't get those pesky warnings, and Apple may even be throwing an exception nowadays if you try to install a UITabBarController as anything other than the root view of the window).
I accept JMStone answer but we might get into situation where we need to put tab bar controller inside other controller especially table view controller.
Please refer Storyboard navigation controller and tab bar controller
and also the good example by Matthjin: http://cl.ly/VQLa
Hopes it help some one who want to put tab bar controller inside table view controller and wants proper navigation.

UINavigationController with UITabBar live bytes

I have a navigation controller with 3 view controllers. The third view controller contains a UITabBar and each tab on the tab bar has its own separate navigation controller. When I'm pushing and popping view controllers on the tab bar navigation controllers, all allocations work fine. They rise and decline accordingly. But when I pop the navigation controller that hosts the tab bar (the third VC) back to the second view controller(a view controller without the tab bar) and then back to the third VC again (the one hosting the the tab bar), the live bytes grow to more than what they were before when previously on that same viewcontroller.
Is there something special I need to do when popping the from the tab bar back to the view controller without the tab bar???
Or any other thoughts
I'm using ARC
I also do not use a sub class of UITabBar to control the tab bar
The problem was I was pushing a uitabbarcontroller onto and navigation stack and from what I understand this is not possible.
So instead I start the app out with the uitabbar and display a separate navigation controller as a modal

Objective C: TabBarController and TableViewController

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

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.