iphone – 正确显示登录屏幕的方式,然后是UITabbarController菜单

我需要实现以下内容,我想知道正确的方法.

当iPhone应用程序启动时,我需要显示2秒的徽标图像,然后显示允许此人登录或创建帐户的登录屏幕.一旦有人登录,我需要显示tabbarcontroller菜单选项.

这就是我目前正在做的事情:

在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;
}

所以,我的问题是:

>这是为我的目的显示标签栏的正确方法吗?
>在这个方案中,我无法显示动画徽标.有关如何做到这一点的任何指示?

最佳答案 下面的代码假设您正在使用ARC,如果您不使用ARC,则需要使用ARC.

- (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];
}
点赞