I want to have 2 view controller with a navigation bar, but without the status bar.
How can I push these two controllers? Is it possible without the navigation controller?
Here is one example
There is no status bar but also with a back button.
Using a UINavigationController (giving you the navigation bar and the back button) is a completely separate task from whether the status bar shows or not.
So use a UINavigationController to properly and easily push and pop your view controllers as needed.
To hide the status bar, please see Hide Status Bar In iOS 8 app.
Related
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.
Keep in mind with the following question, I am still an iOS noob.
So I understand how to hide/show/recolor the navigation bar and whatnot. My next challenge is that some screens need the nav bar and others do not.
When my app starts off, I have the nav bar as hidden and then the user can click register or log in (both of which screens have a nav bar).
So those screens have the code to show the nav bar all while the first (welcome screen) has the code to hide the nav bar.
Here is the question: Why is it that when I first start my app, the nav bar is not there, but when I go to register/login and then hit the back button to return to the welcome page (initial page) then the nav bar is still there, even though my code to hide it is in the viewDidLoad method?
How can I fix this?
You can try moving the logic of hidding the Nav bar to the ViewWillAppear method, you just need to override it in your View Controller class.
Alternatively I would suggest to use a separate view controller to handle your login/registration screens and only use nav bars where you need them. You would have to create a view controller in your story board with your regular screens and embed the screens that need the tab bar in a navigation controller, You can then segue from your regular view controller into the navigation controller that includes your tabs.
Hope this helps
There is one thing i thinking about for days now. I want to keep the same navigation bar on every viewcontroller in my app (like in the amazon app) and show the push animation (push segue) only on the view itself without touching the nav bar.
Is there a simple way to do that?
If both of the views are inside the same UINavigationController, then the nav bar will not be changed at all when you use the push segue. If you don't want any nav bar title animations, etc just set the same title/buttons on the next view, and it will look like nothing changed. When the new view controller is pushed, the nav bar will remain the same, and only what's under it will change.
Is there a way to force the navigation bar of a UINavigationController to be laid out as if the status bar is showing even when the status bar is hidden? My motivation is to prevent the navigation bar for shifting when a navigation controller presents a view controller that returns YES for prefersStatusBarHidden. An example of this is when you look at an attached image in an email in the Gmail app.
I'm just wondering could anyone tell me why the navigation bar and status bar in an app different after it has passed through a navigation controller?
The app I'm working on is a Tab Bar Controller app that has one section with a table view ('More' tab). This view controller that holds the table view is embedded in a navigation controller. The navigation bar and status bar reach further down the page in the 'More' tab and I feel it is something to do with the navigation controller.
I would love if all the tabs had a matching style for the navigation bar and status bar. Apologies if I am not describing this clearly, I can't post images yet as I am just starting out with development and SO.
I suppose I am asking:
How to change the appearance of status and navigation bar in a Navigation Controller?
Any help I get will be gratefully received. Thank you.
Here is the solution you search for:
Question 1:
How to change the appearance of status bar
Question 2:
How to change the appearance of navigation bar or this