Better NavigationController transition in Three20

2019-09-06 20:44发布

问题:

I am using the following codes to switch controller in my Three20 App

TTURLAction * urlAction = [TTURLAction actionWithURLPath:url];
[urlAction applyAnimated:YES];

CATransition * transition = [CATransition animation];
transition.duration = 0.4f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionReveal;
transition.subtype = kCATransitionFromRight;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[[TTNavigator navigator] openURLAction:urlAction];

But the transition is strange and never as smooth as the default Three20 transition, e.g. Move from TTTableViewController to TTViewController

  1. Any one can provide a better codes for a smoother transition?

  2. Is it possible to transit only the content between NavigationController and TabBar? (I mean keep the button in existing NavigationController un-touched)

Thanks.

回答1:

You are in fact animating twice. First you tell three20 to apply animation by [urlAction applyAnimated:YES]; and then you are attaching your own animation.

Remove applyAnimated: and it works just fine. Tested with Three20 1.0.11 on iOS5 Simulator and device.

It might be clever to use [TTNavigator navigator].topController instead of self.navigationController to get the controller which will present the url. This might be an different one under some circumstances.