Starting the login mode before displaying the tab bar controller

I have an ios5 application developed using a storyboard that currently displays a view of the tab bar controller on first run. I would like to display the login screen until the tab bar controller is displayed. The user enters his username and password, then the system will authenticate the user, and then, if successful, displays the tab bar controller.

I tried the following 3 options with no luck .. any ideas?

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Option 1 UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController; PointsViewController *firstVC = [[tabBarController viewControllers] objectAtIndex:0]; UIViewController *loginViewController = [[LoginViewController alloc] init]; [firstVC.navigationController pushViewController:loginViewController animated:YES]; // Option 2 UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController; UIViewController *loginViewController = [[LoginViewController alloc] init]; [tabBarController presentViewController:loginViewController animated:NO completion:nil]; // Option 3 UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController; UIViewController *loginViewController = [[LoginViewController alloc] init]; [tabBarController presentModalViewController:loginViewController animated:NO]; return YES; } 
+7
source share
4 answers

Finally came up with this ... here's what you need to do:

  • Add an offline login to the storyboard.

  • Select the login window and in the attribute inspector, check the "Source view controller." This will switch the initial view launched from the tab controller into the login window, thereby eliminating the whole problem of displaying the login screen.

  • Add a button to the login window and create a segue to load the tab controller with the click of a button. (Or you can create a segue from the login window of the tab controller view and programmatically call segue as needed).

  • Choose your input type and choose Editor> Paste> Navigation Controller

  • In the attribute inspector for the navigation controller, uncheck the "Show navigation bar" box (this is a cosmetic change, I assume that you do not need the navigation bar displayed on the login screen!)

What is it:)

+18
source

Take a look at the following links

stack overflow

link2

reference 3

+2
source

You can use a modal view. You can check if the user is logged in. If not, you can use the modal view to get login information. You can create a UIViewController in the storyboard, and then use the instantiateViewControllerWithIdentifier: method to create the storyboard entry screen. Then just show it in different ways.

0
source

I met this problem just now, and I completely solved it by adding the following code that you also did not use.

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... [self.window makeKeyAndVisible]; } 
0
source

All Articles