2 tab bar controller, 2 nav bar controller linked to ONE view (storyboard) - ios

I've got a problem with my application UI.
I want to link 2 tab bar controller to one view, but I don't know how to represent it?
To give you the context of my application, I have a series of views controller that give some useful support information for my app. I want theses view to be displayed on both of my tab bar controller menu (one tab bar controller is displayed when the user is logged in, and the other when he's not)
I thought of putting a view controller between the tab bar controller and the navigation controller, which could trigger the view I'm looking to display 'twice', but for some reasons I couldnt get it to work. (I'm not sure if it's the best implementation, too)
Here's a screenshot of what my storyboard look like right now:
http://img836.imageshack.us/img836/5913/41321932.png

Related

Navigation bar breaks in Tableview / detail view inside Tab bar controller

This is a bit of a tricky one to explain here so I'm hoping the screenshot of the storyboard of the app I'm trying to build helps to clarify what I'm trying to do.
Basically the apps starts with a nav controller and table view, when you click on a cell in the table view you go to a tab bar controller with three tabs, each tab view has its own navigation controller and subsequently there is a navigation bar on each of them, so at this point there is a back button on all tab views which takes us back to the initial table view.
The first tab view simply has some text, the next has a table view with several table cells and the last has a map view with several markers. Both the table cell and the map markers link to a detail view via a navigation controller which shows more detailed information (both via named segues). It's at this point of clicking through to the detail view where the navigation is breaking, the detail page shows no navigation bar although it is there as the title text is set, but there is no back button and it seems that the navigation context / hierarchy has been broken here somehow. The appearance of the storyboard also reflects this as it shows no Back button on the navbar on the navigation controller or the Detail view.
Without initially getting into the code in any real way I am just trying to see if there is any significant reason why these type of structure / hierarchy is just now going to work. So, my main question is does this storyboard structure seem like the correct way to go about what I'm trying to do?
Here is the storyboard:

Using UITabBarController with UINavigationController - Swift 3

I am making an app which requires a use of a UITabBarController along with UINavigationController. I have made the following flow in storyboard.
See image
Now the first question is that is this accepted by Apple, as there are too many discussions for the same.
The other matter of concern is that is it possible to eliminate any UINavigationController and still get the same flow of the app? The main thing required is to have the SAME tab bar and navigation bar on all sub tabs of the tabs. One point to be noted is that if I remove the second UINavigationController then my app navigates directly from sub tab to home view controller on clicking back button.
I have been stuck on this since hours now. I am new to iOS app development and have never uploaded any app to the app store. Any help would greatly valued.
EDIT :
I put the second navigation controller as shown in the answers - see this flow, But because I have a navigation controller before the HomeViewController, so I am getting a navigation bar at the top and then some empty space below that(exactly equal to the top navigation bar) and then the page contents on runtime. Any solution to this?
Yes, it is acceptable by Apple.
But View hierarchy is not managed correctly. In your case Tab bar will be the root view controller for 2nd navigation controller.
Also, Tab and sub tab you are pushing will be part of 2nd navigation controller.
That's the reason you are getting back on Home view controller.
It's good practice to keep navigation controller to each Tab to manage it's sub-tab hierarchy.
You could present tab bar controller or setviewcontroller from Home View controller.
First embed tab bar controller as in this image and the embed navigation bar controller as in this image finally this will look like

Having problems with combined tab bar and navigation bar controllers

I am having a problem with the back button not going to the previous view controller despite me using segues (via push). I think there is a problem since I saw this line on Apple's documentation saying
"An app that uses a tab bar controller can also use navigation controllers in one or more tabs. When combining these two types of view controller in the same user interface, the tab bar controller always acts as the wrapper for the navigation controllers."
But I want to be able to use a login screen which then moves onto a couple of screens before getting to a tab bar controller therefore not having the navigation bar wrapped in the tab bar controller. I know many popular apps use this, for example Instagram where you login then it shows the tab bar controller.
My current app layout is this;
Root navigation controller -> login -> meals (gif) -> tab controller (navigation controller for each tab (as per link) -> (My Rota/ My Meals/ Shopping List/ Item)
How to implement tab bar controller with navigation controller in right way
It looks like it is behaving as expected, the back button is for your root navigation controller and when you use the 'back' button it pops your tab bar controller. I actually expected you to see two navigation bars, your root one and the one in the My Meals tab, unless you hide one.
You could hide the root navigation bar when you push the tab bar, but you'll probably need a button in each tab's navigation bar which pops the tab bar from the root navigational controller.
Beyowulf's suggestion of presenting it as a modal is another option.

Custom/common toolbar in Swift

I'm quite new to Swift and am working on an app where I'm not sure how to setup the navigation. It works with a tab bar, except that I want the bar to display nomatter what view is being displayed. There are 4 "main" views that the user should always be able to get to. The problem comes when I get into subviews of one of those main views.
I have the tab bar with the 4 icons for the primary views. It's currently displaying the "activity list". When the user clicks on an activity, it will display a list at the next level of detail. However, that view is not one of the primary ones that is represented in the tab bar, so it has no tab bar and no way to transition directly to one of the primary views. You have to back your way out to the Activity list before you can select a different tab.
Say that the main views (represented in the tab bar) are A, B, C, and D. I want to be able to display the same toolbar on all sub-views (e.g. C-1, C-2, etc.) and allow direct transition to any of the other main views, without the user having to manually back out of each sub-view.
What is the "best" way to accomplish this?
1) Should I be creating a custom toolbar object that gets implemented on every view controller?
2) Should it be a combination of tab bar and tool bars?
3) If I have drilled into a stack of views, do I need to pop all of those views individually before I can switch to a different tab?
4) What do I use as my "root" view?
Thanks for any suggestions. I have hunted, but haven't found an example of a scenario quite like this.
I think I figured it out. I needed to embed each "tab" view in a navigation controller.
So...
Tab Bar Controller --> Navigation Controller --> View Controller --> "view stack"
The tab bar now remains at the bottom for every view, and if I touch the tab icon a second time, it goes back to the original tab view controller.

ios: storyboard + tabbar + more button (design)

I have a little app that shows a list of dvds, then you can drill down from the table view and get some details. It also has a tab bar at the bottom and you can switch from dvds to bluray as tab buttons. This all works fine.
In reading about tab bar apps, I saw a demo that once you added more than 5 tab bar buttons, "more" would show up and then you can drag-n-drop the buttons like in Apple's Music app, which is cool! I also noticed that each tab bar button controlled a separate navigation controller, which was a new technique to me.
When I created my app, it had a single navigation controller and I added a view controller with the top of the view being a table view and the bottom of the view a tab bar. I then drag buttons to the button bar and can add more than 5 buttons and "more" doesn't show up.
So, I figure, it needs to to be a different navigation controller design.
I am confused on if I can take my app and embed a tab view controller or if I can adapt what I have or not.
Right now, since all tabs are basically the same (a table that drills down to a detail view) I just reload the data from a different file when the tab is switched. Nice and clean.
If I switched to the tab view controller concept, it seems wasteful to create 5 navigation controllers with 5 table views that drill down to 5 detail views. Plus what if I wanted 7? or 9? (I do realize (or guess) that I can give each 5 views the same class name, but still the UI has lots of storyboards…)
This is a design question to better understand what my options are.
Tab bar controller must always be the root controller of an application. (Unless it's in a split view, in which case the different sides of the split can be a tab bar controller - but it still has to be the root.)
So, the correct design for your app is: tab bar controller as root, each tab containing a navigation controller, each navigation controller having your table view controller as the first view controller. It may seem wasteful but if you think about it, each tab really needs to have its own stack of controllers, so there's no other reasonable way to do it. If user on tab 1 is 2 deep in a nav stack but tab 2 is 7 deep you don't want to switch between tabs and lose your place.

Resources