4

In my app, I set the window's rootViewController in willFinishLaunching. Standard.

In didFinishLaunching, I check to see if the user is logged in, and if not, I present a LoginViewController.

- (BOOL)application:(UIApplication *)application willFinishLaunching...
{
    ...

    self.window.rootViewController = [MyViewController new];
    [self.window makeKeyAndVisible];

    ...

    return true;
}

- (BOOL)application:(UIApplication *)application didFinishLaunching...
{
    if (/* not logged in */) {
        UIViewController *login = [LoginViewController new];
        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:welcome];
        [self.window.rootViewController presentViewController:nav animated:false completion:nil];
    }

    return true;
}

In iOS 7, this works perfectly. However, in iOS 8, I see the following warnings in my console:

Unbalanced calls to begin/end appearance transitions for <LoginViewController: 0x7fca9340cbb0>.

I'm not quite sure what I need to do to avoid this warning while still being able to present my LoginViewController.

I like presenting from window.rootViewController because it allows me to dismiss LoginViewController when the user logs in without having to add completion/callback code to any other view controllers in my application.

Any ideas?

djibouti33
  • 12,102
  • 9
  • 83
  • 116

1 Answers1

0

You need to present view controller with some delay. I have used this trick in one of my project.

-(void)presentController
{
        UIViewController *login = [LoginViewController new];
        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:welcome];
        [self.window.rootViewController presentViewController:nav animated:false completion:nil];
}

call this method with performSelector with delay

 [self performSelector:@selector(presentController) withObject:self afterDelay:1.0];
darshan
  • 1,115
  • 1
  • 14
  • 29