Question

There's a UIViewController method -(void)viewDidUnload. I tried putting NSLog("unloaded"); in there to see when the view is unloaded, but nothing was printed to the console.

Where do I put my code, so that before a view unloads I can perform an action?

Was it helpful?

Solution

Are you using storyboard or not?

Have you tried any of this methods

 -(void) viewWillUnload{}

or

-(void)viewWillDisappear:(BOOL)animated{}

If you are using storyboards the one that will that usually performs is viewWillDisappear.

OTHER TIPS

If you read the viewDidUnload documentation, you see that it's related to low memory conditions and may be called to help with that. There is also a viewWillUnload that get's called before the view is released. It's also related to low memory.

If you're only interested in when the view is no longer seen, there are will/did disappear methods.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top