morais morais - 2 months ago 9
iOS Question

How long is the animation of the transition between views on a UINavigationController?

Ideally, there would be some kind of constant containing this value.

I'm implementing code that has it's own transition animations, and I'd like those to have the same length as the platform transition animations.

Answer

There's no constant containing this value. However, using the following UINavigationControllerDelegate methods:

- (void) navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    startTime = [[NSDate date] retain];
}

- (void) navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    NSLog(@"Duration %f", [[NSDate date] timeIntervalSinceDate: startTime]);
}

... I can see that the duration is approx 0.35 seconds

Interestingly, different parts of the views take different times to transition into place. See this great blog post for more details:

http://watchingapple.com/2009/11/a-closer-look-at-iphone-transition-animations/