How to properly combine a Tab Bar View and Navigation Bar in iOS - ios

In my iOS application I have a tab bar view with three views. I would like each of those views to have a "navigation" bar at the top. I would like the navigation bar to have a left bar button item which has the same functionality across all three views, and then a right bar button item which is unique to each view. How should I build this?

In each tab, put a UINavigationController. That's a separate one for each tab.
Set the root view controller of each navigation controller to a view controller that manages the content view you want to display.
You can set the left button item of each of the three navigation controllers to the same thing, and set the right button item to something different.

Related

Show main TabBar for an item which is not a TabBar Item, but is in Menu(Using SWRevealCotroller)

I am using SWRevealViewController for side menu.
and also I have a tabbar controller as main view in my app.
In my menu I have "MenuItem" (which presents MenuItemViewController) and the tab bar items are "TabItem1" and "TabItem2".
Here is what I need:
Show the tab bar in "MenuItemViewController".
To have back button(bar button) that goes back to the TabItem1ViewController.
I do not want to have a new item for "MenuItem" in my tabbar.
What I Have
What I Need
BTW, the top left view controller is the side menu.
I have something that i think will match your requirement, or maybe you'll get an idea from this.
What's happening here is a tab bar with any number of view is embedded inside a navigation bar. and the menu screen is the rear view of swrevealView and navigation bar is the front view. Ask if you have any doubt.

Tab bar not showing on sub pages during runtime

I have a UITabBarController with 4 tabs, suppose A,B,C and D. I have a table view in page A. On clicking on any of the rows, E page opens.
The problem is that on creating show segue from view controller A to E, the tab bar appears below in E in storyboard, whereas during runtime no tab bar is visible on E. Please could anyone help me out in this.
EDIT :
I can add tab bar item to tab bar of subview as below:
This is the view hierarchy :
Note : I want to the tab bar of the main A-D tabs in all sub pages of A-D
I want to show you two images in different conditions. Maybe it's not a answer but will help you in some manner.
!) I have tab bar controller connected with navigation controller. That Tab bar has two items. "Top Rated" view has a button that connected to other view controller. Check right hand side attribute section for this bottom bar is none.
2)Same condition for second image but this time I changed the bottom bar option of this view controller(check attribute section). Now the view controller has tab bar item.
But this will not show in run time because this is not connected with tab bar controller. One more thing you can easily put tab bar item on new view controller that are not connected with navigation and tab bar controller, but when you run it will not there.
Updated:
This will help you. Try to set navigation inside of tab bar controller. Give tab bar item to navigation controller. Like:
Output is:
When button clicked:
In that manner you can tab bar in all views.
Update 2:
Here I have Navigation then Home view then the above process with tab bar controller and its working fine.
Updated Output:
When button clicked:

iOS tab bar controller adding a navigation button at the top of the controller

So I have a UITabBarController and it has three buttons on the bottom in my iOS app. I want to add another set of buttons at the top but not quite sure on how to do this. I tried adding a UINavigationBar and a navigation button, and adding a view in to it, adding just the buttons, ect.... but to no avail. It won't let me add anything to the UITabBarController. Is there a way to do this?
Thank you very much.
the simplest way to that is to creat 3 buttons side by side and set their frame the way they divide the top of screen to 3 equals. it means u can create a tab bar with buttons manually.
but there's another way. i think this answer would help u
Positioning UITabBar at the top
To use the navigation bar you need a navigation controller. Now depending on your needs your tab bar controller should be inside a navigation controller or the other way around. If you want to be able to navigate away from the tab bar controller (have a screen without the tab bar) you should embed your tab bar controller into a navigation controller. If you only need the navigation bar for some tabs of the tab bar controller or you still want the tab bar to be visible all the time you should embed all (or just the ones than need a navigation bar) your root view controllers for each tab in navigation controllers. Finally if you do not need the navigation behaviour you could just put a regular view in the view controller that needs the bar at the top and some buttons in it and make them look the way you want.
You can embed a view controller in a navigation controller in a storyboard by selecting the view controller and the going to Edit->Embed in->Navigation controller.
Select the Any Tabbar ViewController then above the Menu -> Editor -> Embed In -> Navigation Controller its select, if you get the Navigation Controller then if you add the Navigation Button at Top of the ViewController, example :

How to Add a Bar Button Item on a Disappeared Navigation Bar using Storyboard?

I want to add a bar button item on the navigation bar. (Say View 1 here.) The view that will segue to View 1 is embedded in a navigation controller.
However, the navigation bar is not showing in this view.
If I use attribute inspector to add a opaque/ translucent navigation bar, there will be a navigation bar in View 1. But if I drag in a bar button item, it cannot be shown in the storyboard. Though the bar button is in the document outline, it cannot be shown on the storyboard. Also, if I run the application, it is not on the screen.
When running the application in the simulator, View 1 will have a navigation bar on the top of it, since I use "Show" rather than "Show Details" to show View 1. I tried to embed View 1 in a navigation controller again, but it won't help much.
Can anyone tell me how to add a bar button in this situation using storyboard? And why the navigation bar is missing from the storyboard?
Thanks in advance.
I figure it out by myself.
Drag a Navigation Item from the object list, and then add bar button item to it.
Thanks to rdelmar for his idea, though drag out a navigation bar won't work in the way I thought it should work.
In my situation, View 1 is a table view. Drag a navigation bar to the view will cause it to be the header view for the table, rather than a navigation bar I had expected. Then there will be two navigation bar in the view when I run the application.
Of course we can drag out a navigation bar and add a button to it, it might work different with your expectation. As I had said, it might leads to a view which contains two navigation bars.
You can fix this by drag out the Navigation Item (contains the bar button you had added) inside the Navigation Bar out. In my situation, I drag it out and put it the same level with the table view inside the document outline. Then it won't become the header view for the table view.
After that, we can just delete the navigation bar from the document outline.
I have no idea why the navigation bar disappears in my storyboard. If anyone has some idea for this, please let me know.
It sounds like you're adding the navigation bar by using the Simulated Metrics. If so, this doesn't add one at run time, it's only for layout purposes in IB. You should drag out a navigation bar from the objects list, and add your button to it.

tab bar goes when going between views

I am developing a tabbed bar application using storyboards.
I am attempting to put in a back button one a view - but when I press to go back (from one view to another) the tab bar vanishes.
How can I ensure the tab bar stays there?
Just make sure you're adding the UITabBar to the main Navigation Controller or View Controller of Navigation Hierarchy.
You need to select Tab Bar on the Navigation Controller Bottom Bar under the Attributes Inspector, then set the bottom bar to Inferred for the rest of your pages (or Tab Bar if you want it to be different on any pages)

Resources