Hide tabbar on one viewcontroller Xcode - ios

I have a tabbed application in Xcode. I don't want my user to see the tab bar unless he logs in. My viewcontroller's name is Login

First present the login view controller which handles the input and validation of user credentials.
In case of success, present the tab bar controller either by replacing window root view controller (initially the login controller) or by pushing the tab bar controller on navigation stack (in this case the navigation controller is the initial view controller).

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.

How do I make the login screen with the main tabview controller that makes it open the first time the app is opened

Link to image here
This is the view of the screens
I want
I can't link it to the main tab bar controller
Give the nav controller that parents the login screen a storyboard identifier. Next, create a custom UITabBarController subclass and assign it to the Tab Bar Controller. In its viewDidAppear method, check to see if you need to log in. If so, instantiate the login nav controller via its storyboard ID and present it modally.
Set your login screen as initial view controller. You can set view controller as initial view from attribute inspector. When user login's successfully, present your main tab view controller.

How to segue to a specific view controller inside a tab bar controller with losing the tab bar?

Currently I have a tab bar controller that is connected to various navigation controllers like this:
I'm trying to navigate from one view controller to another view controller that is in a separate navigation controller. The only way I've been able to figure out how to keep the tab bar from disappearing is to create a modal segue to the original tab bar controller. The only problem doing this it automatically goes to the default tab bar viewcontroller and not the one I'm trying to reach.

swift tab bar trying to show login view controller on certain pages

I have just switched my applications navigation into tab bar.
Now I wonder how I can show a login VC when I click on certain tabs.
Before I just made a performSegueWithIdentifier() if the user was not logged in. But how can I do this with a navigation bar bar controller? I dont want the login VC to be displayed as an item in the navigation bar, I only want to show it if the user is not logged in and clicks on a certain tab item
You can have the tab bar controller's view controllers check whether the user is already logged in and if it is required -- present a login few controller if needed, say modally.

login view controller and main tab bar controller

I have an app that should either show a login page or a main tab bar controller.
What's the best way to set this up? For now I'm starting out with an empty view controller and then either presenting a navigation controller for the login flow, or a tab bar controller for the main app. This means the entire contents of my app live within a modally presented view. Is that bad?
How do most people handle this?
I assume most people set the tab bar as their default view and present a modal login controller above it if necessary. Then when you log in you can just dismiss the login controller and you are back at your tab bar controller.
Your method should work just fine though.

Resources