JRV JRV - 4 months ago 58
iOS Question

viewWillDisappear not called when calling popToRootViewControllerAnimated

I work on a legacy application, and have found out, that my

methods are not always fired properly.

The case is, I have a (custom)
set as rootViewController in AppDelegate. This rootViewController has a
, which has two view controllers pushed on it. When the user presses the home button, the user is logged out. When he later returns to the app, the application calls
[UINavigationController popToRootViewControllerAnimated:YES]
and then displays a modal
for logging in.

The problem is: When I push/pop on the
normally, my
method is called properly. But when I use the
is not called on any of the viewControllers that are popped off.

Searching on the internet has only given two possible reasons:

None of these suggestions are the case in my app. And I have no idea where to look. Anybody has a suggestion to what has been done wrong in the app?


The view probably wasn't onscreen. It has to be onscreen (visible) for the viewWillDisappear: method to be called. If it's coming back from the background, it wasn't visible.

You could try using willMoveToParentViewController: which is called when the view controller is removed from its parent.