iPhone SDK的NavigationController提供的动画效果默认只有一种,如何实现各种不同的呢?
下面是来自three20的实现,大家只要把这两个方法作为UINavigationController的Category方法调用就可以了
- (void)pushAnimationDidStop {
}
- (void)pushViewController: (UIViewController*)controller
animatedWithTransition: (UIViewAnimationTransition)transition {
[self pushViewController:controller animated:NO];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75f];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(pushAnimationDidStop)];
[UIView setAnimationTransition:transition forView:self.view cache:YES];
[UIView commitAnimations];
}
- (UIViewController*)popViewControllerAnimatedWithTransition:(UIViewAnimationTransition)transition {
UIViewController* poppedController = [self popViewControllerAnimated:NO];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.75f];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(pushAnimationDidStop)];
[UIView setAnimationTransition:transition forView:self.view cache:NO];
[UIView commitAnimations];
return poppedController;
}
下面是来自three20的实现,大家只要把这两个方法作为UINavigationController的Category方法调用就可以了
- (void)pushAnimationDidStop {
}
- (void)pushViewController: (UIViewController*)controller
animatedWithTransition: (UIViewAnimationTransition)transition {
[self pushViewController:controller animated:NO];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75f];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(pushAnimationDidStop)];
[UIView setAnimationTransition:transition forView:self.view cache:YES];
[UIView commitAnimations];
}
- (UIViewController*)popViewControllerAnimatedWithTransition:(UIViewAnimationTransition)transition {
UIViewController* poppedController = [self popViewControllerAnimated:NO];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.75f];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(pushAnimationDidStop)];
[UIView setAnimationTransition:transition forView:self.view cache:NO];
[UIView commitAnimations];
return poppedController;
}