iosuikitviewcontrollermemory-warning

Why isn't viewDidLoad executed when a UIViewController's view becomes visible?


I am reading a book on iOS programming. Suppose that we have two viewcontrollers (each of them have its own view), at any time, I can only see view of one of them. When the APP is running, I sent a "memory warning" via simulator. According the book, I should observe the hidden viewcontroller's viewDidLoad been triggered again when I "force" the hidden one to show up. But I didn't see it happen.

In other words, "memory warning" are supposed to destroy the view which is not on the screen. But I can't see it.

The book are written for iOS5. I am wondering if there is some behavior change in iOS6+

Thanks


Solution

  • Yes, the behavior changed in iOS 6. Starting in iOS 6, a UIViewController does not unload its view when the system sends a low-memory warning.

    The viewDidUnload documentation is quite clear:

    Deprecated in iOS 6.0. Views are no longer purged under low-memory conditions and so this method is never called.