Question

I've implemented this code in another app, and it worked great. Now, the same code is not working here (I am importing QuartzCore framewok)... The log message IS called. Could anyone help me please? Thanks in advance. This is my code:

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

    // Override point for customization after application launch.
    [NSThread sleepForTimeInterval:1.5];

    CATransition *transition = [CATransition animation];
    transition.delegate = self;
    transition.duration = 1.5;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionFade;

    [[window layer] addAnimation:transition forKey:nil];

    [window addSubview:[navigationController view]];
    [window makeKeyAndVisible];

    return YES;
}

- (void)animationDidStop:(CAAnimation *)theAnimation finished: (BOOL)flag
{
    NSLog(@"Animation did stop!");
}
Was it helpful?

Solution

Move:

    [[window layer] addAnimation:transition forKey:nil];

below:

    [window makeKeyAndVisible];

You're explicitly creating the animation, but you're applying the animation "Before" you want to add the Subview to the Window. By placing it below, you tell the Window that you want to animate the positioning of the subview.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top