login view controller and main tab bar controller - ios

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.

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.

Hide tabbar on one viewcontroller Xcode

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

UINavigationController limited utilization in app design

I am using the NavigationController (Embedded via Editor drop down menu in xCode) to control navigation on sign-up and sign-in views, all from landing view when app first launched.
After user sign-up or login, I would like to initiate a view controller with no relation to the NavigationController. Nonetheless, from Sign-up and Login views, I have a segue that links (upon successful authorization) to the main view of logged in users. How can I remove the navigation controller from a certain part of the application because it is no longer needed? Otherwise, each time I add a new view controller, it shows the navigation bar in it which is not ideal for design.
Thanks and image attached shows what I need illustrated.
As far as I am concerned you can remove only view controller from navigation stack. If you do not want navigation bar to be visible, then just hide it in viewWillAppear of view controller that you want to be without navigationBar.
[self.navigationController setNavigationBarHidden:<#(BOOL)#> animated:<#(BOOL)#>]

Presenting modal view over partial page curl modal view

I have my main menu embedded in a navigation controller. The settings button performs a modal segue to show my settings page which is half a page shown using the partial page curl.
Now on the settings I have a 'legal' button which I want to just display a full screen UITextView with all my legal stuff.
The problem is, when I display the legal view controller using a modal segue, it displays behind the partial page curl.
If I try using a push segue, it crashes because there is no Navigation controller as the settings is shown modally.
Is there a way to present a modal view over the top of a partial page curl?
Thanks
Best option I can think of is managing all your segues in your initial main menu controller.
For example, you can write a delegate method such that, if the user hits 'legal', you dismiss the modal view (from within your main menu controller's .m) using a delegate method, and then in that same method present a new modal view controller for the settings page (with it's parent being the main menu view controller, which can then have another delegate method to dismiss the legal page and present the settings menu).

Resources