Show Login View Controller on Certain Pages of Tab Bar Application Swift - ios

I have a tab bar application with three views. One of these requires the user to login to view the content.
I would like to initially show a login view when the user selects that tab and then after they are authenticated have them skip the login view and go directly to their content.
I've seen on other questions to check for authentication state in the ViewControllers viewWillAppear method and if not authenticated to present the login screen via a modal. However doing this hides the tab bar when showing the login view.
What would be the correct way to set this up?

Related

Swift Navigation Controller show on launch

I create an app that can login, sign up and display list of users by using navigation controller and table view.
When user not logged in, then show the login page, otherwise show to list users page
But when app launching, the navigate controller always show first ether logged in or not. How can I hide that navigate on launching
Edit: initial controller is ViewController, navigation root view is the right one
For this I recommend you to take a different approach. Set your Users View Controller as the initial View Controller, and check if the user is logged in inside viewDidAppear. If they're not logged in, present the login page.
I don't know what happend, I just restart my mac and it run perfectly as expect

How to make a tabbar click show one of two viewControllers, depending if user is logged in?

Users can use the app without having to be logged in. However, if they go to the "profile" tab, of the tabbar, then:
1) if they are logged in, it shows them their profile.
2) if they are not logged in, it shows them a login page.
I can't figure out the best way to have this happen, because, I of course want to maintain the tabbar for both 1 and 2. If I segue with push or push detail from 1->2 or 2->1, the tabbar disappears.
You can subclass and write the UITabBarController. From that class you can set your tab bar view controllers. When setting the view controllers you can check whether the user is loggedIn or not. If user is loggedIn then you can set the view controller as Profile view else you can set the view as login view.
If user is going to login from that screen then you have to update the login view controller tab with profile view controller

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.

how can i add tab bar controller to my middle of my app with navigation controller

I am developing simple app in iOS 7. I need to put a tab bar controller in my middle of my app - middle meaning the first 2 views containing signup and signin view with navigation controller. After login, my home view will be displayed. I want to show tab bar controller on my home view.
Please help me with my first app.
Thank you for your help.
Considering that you will need to go back to Signin if you signout within the app, it would make more sense to keep Home View separate from the Signin View. And if you signin, you just change the root view controller to the Home View.
If you need to have Push Segue between Signin and Home, you can use Tabbar inside Home View and adjust it to do what UITabViewController does and still live in the medium that "it is a 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)#>]

Resources