Hide Navigation Bar in Interface Builder w/ Storyboards - ios

I have a pretty basic storyboard based app, with a UINavigationController, a main view and a secondary view, both of which are in the navigation hierarchy. I’m currently hiding the navigation bar on the main view by using setNavigationBarHidden: as appropriate in viewWillAppear and viewWillDisappear. It seems like there should be a way to do this in Interface Builder, rather than in code. Essentially I’d like the options available in the Simulated Metrics options, but not simulated. Does that exist?

In the scene for the UINavigationController itself, I suppose you could check the hidden button for the nav bar in the Attributes inspector, but that would make the nav bar hidden for all the view controllers in the navigation stack. But that's not what you want.
To hide the nav bar for an individual view controller using IB, you would need to use a stand alone nav bar for each view controller (e.g., drap and drop a Navigation Bar from the object library in IB). To use a stand alone nav bar in a navigation stack would be more work than programmatically hiding the nav bar.

Just uncheck the Attribute Inspector > Shows Navigation Bar in Attribute Inspector

Related

do I need to embed navigation controller if I want to make custom navigation bar view?

I need to make a custom navigation bar, since it will have search bar and some other views, it will be easier if I just make custom view instead of inserting view to navigation controller programatically
like the picture below, there are 2 ways to implement custom navigation bar view, by embedding navigation controller (yellow VCs) and use or just using present modally segue (blue VCs)
personally I will choose to use navigation controller because 'maybe' there are some methods that has already built that I can use. but the problem is, the custom navigation view (red color) in navigation controller it seems overlapped by the actual navigation bar in storyboard, I don't know how to hide the navigation bar from navigation controller in storyboard, even though if I use self.navigationController?.setNavigationBarHidden(true, animated: animated), it won't be a problem.
what is the right approach to make custom navigation bar like this?
In IB the navigation bar is shown only to simulate what it might look like when you run the app. The decision to show this is inferred, by default, by the fact that it is downstream from the navigation controller. Luckily you can change this option.

Tabbed application and navigation bar (with title and icons)

In a tabbed application, is it possible to have a navigation bar WITHOUT having to use an entire UINavigationController as a UIViewController? I simply need a navigation bar to position an icon on the right (it should simply open a modal). Of course, I could "fake" it with a UIView, but it's not very elegant.
This is possible with a UINavigationBar placed on the top of a view controller.
It is possible to create one from the storyboard, too. Look for the "Navigation Bar" element in the IB Inspector.
This will behave just like a navigation controler's nav bar, with the exception of the navigation functions.

Navigation Bar on Modal View Controller

I have a view controller that executed by a modal view (no Navigation Controller connected). I want to have a Navigation Bar on top and be able to change the buttons and title dynamically depending on what the user has selected on the view controller.
I have read that you can set the View Controllers Simulated Metrics to include either a Translucent or Opaque Navigation Bar.
However, after I select this and add a navigation item to it, I can't get it to show the buttons or title and also don't know how to reference it in code.
Can anyone help walk me through it?
Simulated metrics are a design aid to help in laying out your views; the navigation bar you add that way isn't actually added to your controller at run time. You need to drag out a navigation bar from the object list, and add it to your controller's view.
Simulated Metrics is only to simulate, nothing is changed on your app. If you need a Navigation Bar create it programatically or drag out a navigation bar from the object list.

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)

ios - why do some of my screens have a navigation controller and some do not

Below is a storyboard of my app. For some reason, some of the screens have a navigation bar on top, and some do not. How can I add the navigation bar to each of the screens? Any thoughts on what I did incorrectly for this to happen?
Thanks!
There's a couple gotchas here to be aware of:
The Simulated Metrics, as mentioned by #ohr, are just there for convenience when laying out your views. This lets you account for potentially having the 44px navigation bar in place, so you know to layout your UI elements on your view accordingly. This does not mean you have a navigation controller (or navigation bar) actually within the view.
To have a functional navigation bar, you have a couple options:
1) In your Storyboard, embed your UIViewController within a UINavigationController. This can be done by clicking Editor in the Menu, then Embed in -> Navigation Controller. Make sure you have your desired view controller in the storyboard selected.
2) If you just need a one-off navigation bar (say you are displaying a modal and don't need to push views onto the view hierarchy), then you have the option of just dropping a UINavigationBar into your storyboard view controller. You'll just need to wire up the buttons to IBActions to have them perform the desired task.
Hope this helps!

Resources