Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

is "using a modal segue "a good way to present tab bar controller after a login view controller

any ideas

1 Answer

Stone Preston
Stone Preston
42,016 Points

generally you would want the login to be a modal, and the tabBar to be the root view controller. this way if the user is already logged in and has his session cached on disk, he doesnt have to go through and login again. The tabBarController just comes up.

You need to perform a check in viewDidAppear of the first tabBarController's viewController to see if the user is logged in, if hes not, segue to the login view controller, if he is logged in, you dont really have to do anything.

Stone Preston Amit Bijlani Ben Jakuben the error message :<UITabBarController: 0x9a82490> whose view is not in the window hierarchy!

//in the app delegate.h @property(strong,nonatomic)UITabBarController *tabBarController; // in the app delegate.m

                    UIStoryboard *storyboard=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
                   UITabBarController *tabBarController =(UITabBarController*)self.window.rootViewController;

                    LoginViewController *logincontroller=[storyboard instantiateViewControllerWithIdentifier:@"log"];

                      [tabBarController presentViewController:logincontroller animated:YES completion:NULL];