views:

506

answers:

3

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?

A: 

-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.

Giao
Ok so in -viewDidDissapear i should put something like [self dealloc]? Or what about this, in the rootviewcontroller, putting something like if(self.viewControllerOne !=nil){ self.viewControllerOne = nil;} ??
RexOnRoids
You shouldn't call dealloc manually. -dealloc is handled by the runtime. Release whatever you need to release in -viewDidDisappear.
Giao
What about the 'nil' suggestion I said?
RexOnRoids
That doesn't guarantee that will do what you want it to do.
Giao
It seemed to do the trick. I just am worried that it may cause probs later on down the line.
RexOnRoids
A: 

what exactly do you want?

Rahul Vyas
A: 

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

Matt