Remove ViewController from memory

Hopefully load the ViewController and do something and then unload (viewDidUnload) from memory.

 if (self.vViewController5.view.superview==nil)
 {

  ViewController5 *blueController = 
  [[ViewController5 alloc] initWithNibName:@"View5" bundle:nil];

  self.vViewController5 = blueController;

  [self.vViewController5 setDelegate:self];
  [blueController release];
 }



 [self presentModalViewController:vViewController5 animated:YES]; 

      

later, call

 [self dismissModalViewControllerAnimated:YES];

      

but I found that the offsetModalViewControllerAnimated function does not trigger the viewDidUnload event of the Viewcontroller5.

I am trying to execute a function, but it caused the program to crash. I am also trying to removeFromSuperView, but it is not raising the ViewDidUnload event.

Any comment welcome

thanks

InterDev

+2


a source to share


2 answers


viewDidUnload

only called when your application receives a memory warning and the view is inactive. It is commonly used to release stored views (including IBOutlets). You can use viewWillDisappear

or viewDidDisappear

to respond to a dismissal ( dealloc

will also be called eventually, but not necessarily exactly when the submission is dismissed).



+5


a source


A rejected UIViewController will not fire viewDidUnload as you discovered. However, this will call the viewWillDisappear method if it suits your needs.



+1


a source







All Articles