Navigation controller back button doesnt appear? - ios

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".

Related

Pushing viewController which is not in tab controller without hiding the tab bar

I have a tab controller in which five viewControllers are there. I even have a side menu bar which has the list of other viewControllers . My problem is when i try to click any list to move to viewController it get pushed over the screen, hiding the tab bar at the bottom. How can i show the tab bar at bottom for this scenario. I got some ideas but it dint helped.
You need to make sure that your tab bar controller is you root view controller.
Your story board should look like
tabbarController -> NavigationController -> VC1 -> VC2
Your VC1 to VC2 segue has to be a show segue, not a present modally because the second one makes V2 the root view controller.

Navigation Bar not showing in embed Navigation Controller

I'm trying to display the navigation bar at the top of the screen, but it's not showing in embed navigation controller.
Here is how it is in the storyboard:
And here it's in the simulator:
As you can see, I created a custom TabBar (following this tutorial) at the bottom of the screen so I can navigate between the different views.
I believe that I'm going to have to load the navbar programatically because the only solution that I found was to set the navigation controller as the initial view controller, but I already set another view as the initial one so I can't do that.
Issue :
When you instantiate a viewController using storyBoard identifier they wont come with free embedded navigation controller, even if you have added a NavigationController to them. As a result you are adding a viewController without navigation bar to your tab bar VC.
Solutions:
Solution1: If you want each child viewControllers to carry their own navigation controller hence their own navigation stack, provide a storyboard identifier to Navigation Controller behind your child viewControllers and instantiate the Navigation controller itself rather than ViewController. And add NavigationController as you tab bar looking VC's child. Because navigation controller loads the embdedded VC by default you will see your child VC with nav bar.
Solution2: All that you care for is only nav bar than add the Navigation Controller behind the VC containing tab bar looking View.
Hope it helps
Have you tried constraining the navigation bar to your view? Otherwise it can move offscreen.
You need to point the tab bar controller segue to the navigation controller of your view - otherwise if you point the segue straight to the view you're just loading the view without any navigation controller attached.

Show navigation bar in swrevealviewcontroller

I am using SWRevealViewController for side menu in my app. While choose one of the menu navigationbar hides automatically. I want to show the navigation bar always. I have tried following codes in my ViewController's viewDidLoad().
self.revealViewController().navigationController?.navigationBarHidden = false
and
self.navigationController?.navigationBarHidden = false
But both are not working.
I have followed https://www.youtube.com/watch?v=8EFfPT3UeWs to implement SWRevealViewController in swift based app.
Please Add a navigation controller between your sw_front navigation controller and view controller and hide the navigation bar of first navigation controller using attribute inspector.
To add navigation controller you need to select view controller and go to
Editor -> Embed In ->Navigation Controller
Your Menu (rear)VC can control this if you have it there then it always there unless you hide.

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.

Change from one navigation controller to another

I have application with 2 tab bars. In second tab bar I have navigation controller. I want to change this navigation controller to another navigation controller when "Change" button is pressed. How can I do that? Please help me.
Thanks
You'd have to replace the View Controller in the TabBar using the viewControllers property of UITabBarController or setViewControllers:animated:if you want to add some animation.
But maybe you should think of having 2 views in a controller of yours and hide/show them when you click a button, maybe even pushing/popping view controllers without animation (pushViewController:yourController animated:NO) on the navigation stack of your navigation controller and just hide the back button (self.navigationItem.hidesBackButton = YES)

Resources