The correct way to display the login screen and then the UITabbarController menu

I need to implement the following, and I wanted to know the correct way to do this.

when the iPhone application starts, I need to show the logo image for 2 seconds, and then show the login screen, which allows the person to log in or create an account. When the user logs in, I need to show the tabbarcontroller menu options.

Here's how I do it now:

In AppDelegate :

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { LoginViewController *viewController0 = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil]; UINavigationController *aNavigationController0 = [[UINavigationController alloc] initWithRootViewController:viewController0]; self.window.rootViewController = aNavigationController0; // I also implement an iVar of the UITabBarController here... // .... } 

@implementation :

 @implementation LoginViewController - (IBAction)createNewAccountButtonClicked:(id)sender { AppDelegate *delegate = [[UIApplication sharedApplication] delegate]; delegate.window.rootViewController = delegate.tabBarController; } 

So my questions are:

  • Is this the right way to show a tab for my purpose?

  • In this circuit of things, I cannot show an animated logo. Any pointers on how to do this?

+4
source share
1 answer

The code below assumes you are using ARC, if not, you need to make your MRC.

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil]; self.window.rootViewController = self.tabBarController; LoginViewController *loginViewController= [[LoginViewController alloc] initWithNibName:nil bundle:nil]; loginViewController.delegate = self; UINavigationController *loginNavCont = [[UINavigationController alloc] initWithRootViewController:loginViewController]; [self.tabBarController presentModalViewController:loginNavCont animated:NO]; UIImageView *splashScreen = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default"]]; [self.window addSubview:splashScreen]; [UIView animateWithDuration:0.5 delay:2.0 options:0 animations:^{ splashScreen.alpha = 0.0; } completion:^(BOOL finished) { [splashScreen removeFromSuperview]; }]; [self.window makeKeyAndVisible]; return YES; } - (void)loginViewControllerShouldBeDismissed:(UIViewController *)viewController { [self.tabBarController dismissModalViewControllerAnimated:YES]; } 
+2
source

All Articles