2
votes

Using a navigation based view hierarchy. I have a root view controller, and multiple view controllers that branch out from the same when a button is pressed. When a user presses the back button on the UINavigationBar, the current viewcontroller is popped and the display animates back to the rootviewcontroller.

The problem is, I want the viewcontrollers to UNLOAD whenever they are popped. Seems like they are not unloading because when I go back to them they are still in the state they were when they were popped.

How do I unload the viewcontrollers after navigating back to the rootviewcontroller?

3

3 Answers

1
votes

-viewUnload is called after the application receives low-memory notification.

It is the default implementation of -didReceiveMemoryWarning that calls -viewUnload.

What you probably want to do is put what you want to do into -viewDidDisappear based on what you've described.

0
votes

When you pop a viewcontroller from a navigationcontroller, there should be no more references to the viewcontroller left and the viewcontroller should be deallocated at that time. This should give you the results you expected. You can test if the viewcontroller is being deallocated by adding a break point in -dealloc method.

If dealloc does not get called, check if there is a retain cycle. Specifically check if a child object is retaining the viewcontroller.

-3
votes

in -viewDidDisappear why not [self release]; just need to make sure you have a lazy loader so it will load back when needed.