I use the following code as an extension to UINavigationController to push a view controller with a custom animation:
@implementation UINavigationController (PushAnimation)
- (void)pushViewController:(UIViewController*)controller withTransition:(UIViewAnimationTransition)transition
{
[UIView beginAnimations:nil context:NULL];
[self pushViewController:controller animated:NO];
[UIView setAnimationDuration:1.0];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:transition forView:self.view cache:YES];
[UIView commitAnimations];
}
@end
With caching enabled, I get a strange animation behaviour when pushing a UITableViewController. The title of the pushed view appears after the custom animation is completed. With the transition style UIViewAnimationTransitionNone, it becomes clear that the title itself is animated. It is moved from the top left corner of the screen into the center of the UINavigationBar.
With caching disabled, this animation is not visible due to its speed, but the frame rate drops significantly.
How can I prevent the title from being animated?
Just a quick update what my fix was in the end. It was not possible to override the default behaviour of
UINavigationBar, since iOS uses private API to implement the animation. So I ended up removing all animations on theUINavigationBar, and its various subviews, using the following code:It is important that this is called after
[self pushViewController:controller animated:NO];.