ViewDidDisappear not called

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.

+4
source share
1 answer

I finally asked Apple Technical Support the same question. They concluded that this was a bug in iOS, so I published a bug report for Apple. The same error appears in iOS 6 and in the latest version of iOS 7 (Beta 5).

Apple tech support suggested the following:

As a workaround, you can move the cleanup code to a separate method that AppDelegate will then call the top-level controller on the controller of the navigation controller before it pulls out the entire navigation stack.

However, I think this is too detailed for my data in the view controller, so I decided to implement it using willMoveToParentViewController: This method is called when the view manager is removed from its parent, and it is called correctly.

+7
source

Source: https://habr.com/ru/post/1495969/


All Articles