morais morais - 1 year ago 67
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 Source

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:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download