Search code examples
iosmemory-managementviewdidunloadmemory-warning

viewDidUnload not called for alloc/init initialized viewcontroller with no xib file


Why isn't viewDidUnload method called, when I'm not using xib and use alloc/init to initialize my ViewController when i simulate memory warning for any iOS version via Simulator? It seems as if this method is never called.

If I create controller via alloc/initWithNibName with xib file, viewDidUnload method successfully called. Why does it happend? Does xib file is reqired for all viewcontrollers to normal handling of memory warnings?


Solution

  • I solve my problem. My implementation with no xib just need to add this code:

    - (void) loadView {
       UIView * myView = [[[UIView alloc] init] autorelease];
       self.view = myView;
    }