zlajo zlajo -4 years ago 176
iOS Question

Prevent UINavigationBar popViewController animation

I have the following problem: I have overridden

because I would like to have a custom animation. The code is as follows:

- (UIViewController *)popViewControllerAnimated:(BOOL)animated
UIViewController *poppedCtrl = [super popViewControllerAnimated:NO];
[((customViewController *) self.topViewController) doCustomAnimation];
return poppedCtrl;

Unfortunately the
seems to ignore that I explicitly disable the built in animation and it is still animated.

What do I have to do to also prevent the animation of the navigation bar?

Answer Source

After some reading and also some experimentation I finally found out what needs to be done to achieve the desired behavior.

To prevent the navigation bar from being animated it is not sufficient to override (UIViewController *)popViewControllerAnimated:(BOOL)animated. It is also necessary to create a custom navigation bar and override (UINavigationItem *)popNavigationItemAnimated:(BOOL)animated:

- (UINavigationItem *)popNavigationItemAnimated:(BOOL)animated {
    return [super popNavigationItemAnimated:NO];

Of course this custom navigation bar must also be the one which is used (I just replaced the navigation bar which is used by my navigation controller in the interface builder).

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