0

I am currently updating an older app that is using ARC but not Storyboards. The app starts with an animated launch screen(well seamlessly animated after the launch screen has finished loading), since I started playing with the app in Xcode 6, when I launch the app, I see the loading screen appear, then I see a flash of the nav controller(root controller) then the animation starts. Normally, the app should load in that order --> Default screen --> Seamless animation --> nav controller

The animation works well, and the app loads correctly, it's just that gap between the default launch screen and the animation that I get a glimpse of the nav controller

I'm not entirely certain if it's an iOS issue or Xcode.

I'm adding the code here, anybody else having this issue?

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.tabBarController = [[UITabBarController alloc] init];
    if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
        [self.tabBarController.tabBar setTintColor:[UIColor colorWithRed:0.1960784314 green:0.66666666669999997 blue:0.2784313725 alpha:1.0]];
        [self.tabBarController.tabBar setBarTintColor:[UIColor blackColor]];
    }
    self.window.rootViewController = self.tabBarController;

    NavigationController *navController1, *navController2, *navController3, *navController4, *navController5;
    navController1 = [[NavigationController alloc] initWithRootViewController:[[ViewController1 alloc] initWithNibName:@"ViewController1" bundle:nil]];
    navController2 = [[NavigationController alloc] initWithRootViewController:[[ViewController2 alloc] initWithNibName:@"ViewController2" bundle:nil]];
    navController3 = [[NavigationController alloc] initWithRootViewController:[[ViewController3 alloc] initWithNibName:@"ViewController3" bundle:nil]];
    navController4 = [[NavigationController alloc] initWithRootViewController:[[ViewController4 alloc] initWithNibName:@"ViewController4" bundle:nil]];
    navController5 = [[NavigationController alloc] initWithRootViewController:[[ViewController5 alloc] initWithNibName:@"ViewController5" bundle:nil]];
    self.tabBarController.viewControllers = @[navController1, navController2, navController3, navController4, navController5];

    [self.window makeKeyAndVisible];
    // Display intro view controller
    if (!launchOptions) {
        IntroViewController *introController = [[XMWelcomeViewController alloc] initWithNibName:@"IntroViewController" bundle:nil];
        [introController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
        [self.tabBarController presentViewController:welcomeController animated:NO completion:nil];
    }

    return YES;
}

IntroViewController.m

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    XMLanguageType selectedLanguage = (XMLanguageType)[[NSUserDefaults standardUserDefaults] integerForKey:kUserDefaultsLanguageKey];
    NSString *languageIdentifier = nil;
    switch (selectedLanguage) {
        case XMLanguageTypeEnglish:
            languageIdentifier = @"en";
            break;
        case XMLanguageTypeFrench:
            languageIdentifier = @"fr";
            break;
        default:
            break;
    }
    NSMutableArray *introImages = [NSMutableArray array];

    // Add language specific animation images
    for (int count = 1; count <= 13; count++) {
        NSString *imageName;
        if ([[UIScreen mainScreen] bounds].size.height == 568) {
            imageName = [NSString stringWithFormat:@"intro_animation_%@%04d-586h@2x.jpg", languageIdentifier, count];
        }
        else {
            imageName = [NSString stringWithFormat:@"intro_animation_%@%04d.jpg", languageIdentifier, count];
        }
        UIImage *image = [UIImage imageNamed:imageName];
        [introImages addObject:image];
    }

    [self.imageViewTop setImage:introImages.lastObject];
    [self.imageViewTop setAnimationImages:(NSArray *)introImages];
    [self.imageViewTop setAnimationDuration:1.6];
    [self.imageViewTop setAnimationRepeatCount:1];
    [self.imageViewTop startAnimating];

    // First Launch --> set update on startup to 
    if (![[NSUserDefaults standardUserDefaults] boolForKey:kUserDefaultsFirstLaunchedOccured]) {
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:kUserDefaultsFirstLaunchedOccured];
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:kUserDefaultsUpdateOnStartupKey];
    }
}
PhilBlais
  • 1,076
  • 4
  • 13
  • 36
  • In `AppDelegate.m` if you move `[self.window makeKeyAndVisible];` down to just before your `return YES;` does it fix things? – Kai Schaller Nov 21 '14 at 06:25
  • I tried that and unfortunately it doesn't fix the problem. Actually the animation is never triggered if I do that – PhilBlais Nov 21 '14 at 06:28
  • 1
    Seems like this might be a common problem people are having with iOS 8. Check this question and its responses for some potential workarounds: http://stackoverflow.com/questions/25852477/presentviewcontroller-in-appdelegate-with-delay-in-ios8 – Kai Schaller Nov 21 '14 at 06:34
  • Thanks its good to know that it's a more common problem, it will be quite helpful in trying to create my own workaround – PhilBlais Nov 21 '14 at 06:38

0 Answers0