SWRevealController not working with NavigationController - ios

In my previous question, i asked about including a log in page with my SWRevealController slide out menu before moving onto a home page. The solution was the following set up:
However, i need a navigation bar in order to house the button to open the menu (the navigation bar wont cover the status bar). When i insert a NavigationController in the following way, the menu no longer works
Why does this happen?

Put your Navigation Controller before Login/Signup Controller, then in viewWillAppear of Login/Signup Controller, hide the navigation bar

Related

Navigating within Tab Controller

I am pretty new to Xcode and Swift (though plenty of experience with other languages) and am stuck on a rather trivial problem.
I set up a basic login/register page that goes into the main page of the app (a tab view controller) but I want there to be a unique navigation bar per tab. In the First Tab (Main View Controller) I want to be able to Log Out (go all the way back to the Login screen) as well as click the "+" which will show a new view controller. I had this all working before adding the Tab Controller.
Now that I have the Tab Controller, the Tab Controller is overriding the navigation bar section and I am stuck with the standard "< Back" button on the navigation bar. I have tried some tricks with hiding and showing navigation bars but no luck. My First Tab (Main View Controller) now only shows the "< Back" and not the Log Out and "+".
Furthermore, once the Log Out button is showing I need to get it to go all the way back to the login screen. I attached a picture to help.
XCode: 14.2
Swift: 5.7
Here's how I would setup the storyboard. Start by ignoring the need to login for a moment.
Make the tab bar controller the initial view controller of your storyboard.
Each tab of the tab bar controller should have its own navigation controller, if needed. In other words, a tab can either be a single view controller or it can be a stack of view controllers managed by a tab-specific navigation controller.
Now add the login controller as a controller that is presented modally over the tab bar controller.
On app startup you can immediately present the login controller over the tab bar controller if the user needs to login. Once the user successfully logs in you dismiss the login controller revealing the tab bar controller.
Later on when the user chooses to logout you present the login controller modally over the tab bar controller again.

Having problems with combined tab bar and navigation bar controllers

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.

navigation bar states, showing and hiding the bottom nav bar

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

Tab Bar Disappearing After a Segue

I looked at the following two resources: Tab bar disappears after segue and My Tab bar controller disappears after a push segue. However, both of them are in Objective-C and they don't seem to address the issue that I am having.
Here is my Main Story Board:
Zoomed in is:
Now, let's call the view controller that has Sign Up and Log In VC1 and the one with the Facebook button, VC2. When I go to VC1 from the Tab Bar Controller, everything is good. I have the tab bar on the bottom of my VC1. And I tap Sign Up and the tab bar is gone. Which I want. And when I go back to VC1 (there is a navigation bar on VC2 with the button cancel that I programmatically added in, and when clicked on, takes me to VC1), the tab bar is gone. But I want the tab bar there.
Some people have suggested me to use a navigation controller. But I do not want to use it because I don't want the tab bar to appear when the user clicks on Sign Up. And, the navigation controller only allows for right to left and left to right segues and I want custom segues (I tried customizing the segues for a navigation controller and it caused a crash for me).
So my question is, does anybody know how to keep the tab bar on VC1 AFTER going to another View Controller WITHOUT a tab bar, and going back to VC1 WITH the tab bar?
Sorry for the long post.

Implementing a slide-out menu bar after a login screen in xcode

I have been following the appcoda tutorial (http://www.appcoda.com/ios-programming-sidebar-navigation-menu/) on how to implement a slide-out menu bar for my app using SWRevealViewController. I am wanting to show the slide out menu after the user has logged in.
My root view is the login page. I created a reveal view controller like the tutorial, and put it after the login page. However, when I get to my root view, it displays a back button instead of my slide out bar. In the console, I am getting errors such as "Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted." and "nested push animation can result in corrupted navigation bar".
I have attached an image of my storyboard. Would I need to implement another navigation controlller in the storyboard?
When you navigate from your login View controller to SWRevealViewController, you should hide the navigation bar, which covers the other navigation bar inside SWRevealViewController.
What I did is to hide the first navigation controller's navigation bar in prepareForSegue function of login page controller.

Resources