I am working on an application where I had a problem with my view [Will / Did] Disappearing methods do not start when I return to the application.
The thing is, I have a UINavigationController that has two view controllers. When the user clicks the home button, the user logs out. When it later returns to the application, the following (simplified) code will be launched in my AppDelegate:
- (void)applicationDidBecomeActive:(UIApplication *)application { [(UINavigationController *)self.window.rootViewController popToRootViewControllerAnimated:NO]; [self.window.rootViewController presentModalViewController:loginViewController animated:NO]; }
When I exit view controllers in the navigation controller stack, I expect the view[will|did]disappear methods to be called. However, this is not so, since they (apparently) do not appear on the screen when iOS is about to launch these methods. The modal view controller seems to have taken over.
If I don't imagine a modal view controller, the view[will|did]disappear methods are called expected.
My question is: if I want the view[will|did]disappear methods to be called, how can I structure my code? Is there a better place to introduce my modal loginViewController?
Edit:
To show my problems more clearly, I created a very simple test project here: https://github.com/JohanVase/ModalViewCauseMissingViewDisappearCalls . Try several times to follow the instructions in the application, and make sure that I do not get my "resources" released in my viewWillDisappear method.
source share