I want to realize application with login page.
I’ve got the separate authorization page based on UIViewController with xib file, which user should see first when app loaded and I’ve got main application based on UITabBarController in MainStoryboard.storyboard, where user should redirect after success login.
To launch app with the login page I do in AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
NewUserViewController *controller = [[NewUserViewController alloc] init];
self.window.rootViewController = controller;
[self.window makeKeyAndVisible];
How can I switch to UITabBarController from NewUserViewController after success login?
I try to (in NewUserViewController.m)
MainTabBarViewController *myViewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:NULL] instantiateViewControllerWithIdentifier:@"MainTabBarViewController"];
[self.navigationController pushViewController:myViewController animated:YES];
If you can offer another structure of this app I will happy!
I’m sorry for my English.
You can’t push to the tab bar controller because its not embedded in a navigation controller. I think a better structure is to make the tab bar controller the root controller of the window, then present your login controller modally from the viewDidAppear method of the controller in the first tab. If the login is successful, just dismiss the login controller, and your ready to go. If the login fails, present another view explaining to the user what happened, and go back to the login controller for another try.