popViewControllerAnimated animation is not working

1.9k views Asked by At

I know this is kind of repetitive question in SO, but I'm still unable to figure it out. The animation is not working when the app goes to background and then comes back up. The first time the app launchs I'm able to get the push/pop animation between the views, but once the app goes to background, it stops animating anymore.

I have created a custom navigation controller class extending UINavigationController and written the popViewControllerAnimated method in it.

- (UIViewController *)popViewControllerAnimated:(BOOL)animated {
    UIViewController* viewController = [super popViewControllerAnimated:animated];    
    UIViewController* nextViewControler = [[self viewControllers] lastObject];
    [nextViewControler viewWillAppear:animated];    
    [viewController viewWillDisappear:animated];
    return viewController;
}

Any help is appreciated.

3

There are 3 answers

1
binarymochi On

You might want to try just using the UINavigationControllerDelegate protocol to cause viewWillAppear/viewDidAppear to be called. For more details see:

http://www.idev101.com/code/User_Interface/UINavigationController/viewWillAppear.html

0
Mateusz Grzegorzek On

On my end it was missing call [super viewDidAppear:animated] in my UITabBarController.

It actually produced some other strange behavior, so I'd recommend to always call [super viewWill/Did*] methods

0
Miha Hribar On

This happens if somewhere in your code you are either forcing a call to one of the viewWillAppear counterparts with YES or NO instead of letting iOS decide, or if you mismatch calls to [super viewWillAppear:animated] with viewDidAppear.