Tab Bar Item disappears after adding Navigation Controller - ios

First I created a VC with TabBarController like this.
The other tabs and the main controller are at other storyboards.
Then, I added the Navigation Controller from the Editor > Embed In > Navigation Controller.
And the TabBarItem immediately disappears.
How can I change my tab bar icons and names?

In your storyboard you can change the tab icon from the Navigation controller. (Provided you have different navigation controllers for different tabs of your tab bar controller). YOUR NC will look something like this. (NC -> VC)

I checked your attach images. There are no issue with your navigation controller it will work fine with your tab bar.

Related

How to change the view in one tab of an UITabBar? [duplicate]

I am using Storyboard and Xcode 6. I have next controllers and scenes in my Storyboard:
UINavigationController that has HomeViewController as a root. HomeViewController has a button that Show (e.g. Push) UITabBarController. UITabBarController has 4 UIViewControllers.
But my problem that after I Show UITabBarController there are no Navigation Bars in 4 UIViewControllers. But I supposed that if I Show (e.g. Push) UITabBarController then it should has embedded navigation controller that is initial controller in storyboard. Am I right? And if so how can I setup then navigation bar in Storyboard, because there are now default bar event in pushed tab bar that I see on storyboard. I have selected UIViewController and set simulated metrics in identity inspector to Translucent Navigation bar for the Top property, but I supposed it should be automatically added to this controller and to the tab bar without additional steps.
Or should I add new navigation controller for each tab bar items that will have their root view controllers?
The main question why I don't see navigation bar in storyboard using show (e.g. Push). For example if I add navigation controller and then set as root - tab bar controller then Xcode automatically add top navigation bar, but if the queue has an extra step like in my case HomeViewController the top navigation bar never appear automatically.
Hi you need to embed each view controller that is within the tab bar in a navigation controller of its own. So the flow is like so (HomeVC is embedded in a NavController of it's own):
/ --> `NavController` --> `ViewController1`
| --> `NavController` --> `ViewController2`
`HomeViewController`-->`TabBarController`|--> `NavController` --> `ViewController3`
\--> `NavController` --> `ViewController4`
Go to Editor --> Embed In --> Tab Bar Controller (or Navigation Controller)
To answer your questions:
Each tab of a tab bar controller interface is associated with a custom (different [sic]) view controller. When the user selects a specific tab, the tab bar controller displays the root view of the corresponding view controller, replacing any previous views.
So the Root View Controller of the tab must be adjoined to a Navigation Controller; a navigation view controller must be next inline in order for the View Controller to inherit a Navigation. A Tab Bar switches views to whatever is next inline.
This document will help outline more information about it. https://developer.apple.com/documentation/uikit/uitabbarcontroller
In Swift 2, Xcode 7 has a very handy feature for adding a UINavigationController:
Select the UIViewController that is being used as a "tab" for the UITabBarNavigationController
On the top Xcode menu, select "Editor" ->
"Embed In" ->
"Navigation Controller"
If you want to have something like that:
TabBarController -> Navigation Controller -> View Controller with a Table View -> and from the TableView a MasterDetailView for example:
I had the problem that there were no Navigation in the MasterDetailView (no Back Button to the ViewController with The TableView).
Workaround is:
Set Segue between TableView and MasterDetailView to:
Kind: Push (Deprecated)
Run your app...hopefully you will see the Back Button...change the Kind to Show (e.g. Push), run again -> it should work.

Navigation controller back button doesnt appear?

I'm trying to setup back button on the navigation controller but it doesn't appear when I run it. I watched some tutorials and it usually works.
Your flow should be:
NavigationController --> MainVC --> FoodVC
Now you can add button as follow:
Navigation Item -> Left Bar Button Items -> Bar Button Item -> back button
Go to navigation controller scene -> navigation controller ->navigation bar - then go to right top show attributes option and change bar tint color.Try it
The view controller food is embedded in Navigation Controller , hence it is root view controller.
Navigation bar will appear when any viewController is push on same navigation controller.
So, If you tableview is already in Navigationcontroller then remove Navigation Controller in which Your FoodVC Controller is embedded.
If you want that navigation controller, you may add leftBarButtonItem programatically.
Totally depends on your requirement.
Is MenuVc your main Controller? try this, delete that navigation controller in the middle. Then click the MenuVc, embed in Navigation Controller and set the navigation controller as initial view controller at the attribute inspector. then navigate the menuVC to Food, "Show".

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 :

Swift-How do I add Tab Bar AND Navigation Bar to a single view controller?

Using XCode, and either through Code or through the Storyboard, can someone please explain to me how to add both a Tab Bar and Nav Bar to my view controller while keeping both visible?
Thanks so much.
In your Storyboard, you should drag out a Tab Bar Controller and use that as the initial view controller. Then, you should embed each of the view controllers attached to the Tab Bar Controller inside Navigation Controllers (Editor menu: Embed In > Navigation Controller). Afterward, your Storyboard should look something like this:
The tab bar controller holds a tab bar and will manage switching between the other views attached to it, while the navigation controllers will place Navigation Bars at the top of each tab and help you manage navigation within the tab.
I am assuming you want something like this. Here is how I did it in Interface Builder:
Click your view controller.
Editor -> Embed In -> Navigation Controller
Reselect your view controller.
Editor -> Embed In -> Tab Bar Controller
Select the Navigation Controller
Check the box next to Is Initial View Controller
Hope this helps!

How to implement tab bar controller with navigation controller in right way

I am using Storyboard and Xcode 6. I have next controllers and scenes in my Storyboard:
UINavigationController that has HomeViewController as a root. HomeViewController has a button that Show (e.g. Push) UITabBarController. UITabBarController has 4 UIViewControllers.
But my problem that after I Show UITabBarController there are no Navigation Bars in 4 UIViewControllers. But I supposed that if I Show (e.g. Push) UITabBarController then it should has embedded navigation controller that is initial controller in storyboard. Am I right? And if so how can I setup then navigation bar in Storyboard, because there are now default bar event in pushed tab bar that I see on storyboard. I have selected UIViewController and set simulated metrics in identity inspector to Translucent Navigation bar for the Top property, but I supposed it should be automatically added to this controller and to the tab bar without additional steps.
Or should I add new navigation controller for each tab bar items that will have their root view controllers?
The main question why I don't see navigation bar in storyboard using show (e.g. Push). For example if I add navigation controller and then set as root - tab bar controller then Xcode automatically add top navigation bar, but if the queue has an extra step like in my case HomeViewController the top navigation bar never appear automatically.
Hi you need to embed each view controller that is within the tab bar in a navigation controller of its own. So the flow is like so (HomeVC is embedded in a NavController of it's own):
/ --> `NavController` --> `ViewController1`
| --> `NavController` --> `ViewController2`
`HomeViewController`-->`TabBarController`|--> `NavController` --> `ViewController3`
\--> `NavController` --> `ViewController4`
Go to Editor --> Embed In --> Tab Bar Controller (or Navigation Controller)
To answer your questions:
Each tab of a tab bar controller interface is associated with a custom (different [sic]) view controller. When the user selects a specific tab, the tab bar controller displays the root view of the corresponding view controller, replacing any previous views.
So the Root View Controller of the tab must be adjoined to a Navigation Controller; a navigation view controller must be next inline in order for the View Controller to inherit a Navigation. A Tab Bar switches views to whatever is next inline.
This document will help outline more information about it. https://developer.apple.com/documentation/uikit/uitabbarcontroller
In Swift 2, Xcode 7 has a very handy feature for adding a UINavigationController:
Select the UIViewController that is being used as a "tab" for the UITabBarNavigationController
On the top Xcode menu, select "Editor" ->
"Embed In" ->
"Navigation Controller"
If you want to have something like that:
TabBarController -> Navigation Controller -> View Controller with a Table View -> and from the TableView a MasterDetailView for example:
I had the problem that there were no Navigation in the MasterDetailView (no Back Button to the ViewController with The TableView).
Workaround is:
Set Segue between TableView and MasterDetailView to:
Kind: Push (Deprecated)
Run your app...hopefully you will see the Back Button...change the Kind to Show (e.g. Push), run again -> it should work.

Resources