Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
390 views
in Technique[技术] by (71.8m points)

iphone - When is UIViewController viewDidUnload called?

Note: This question is outdated—viewDidUnload is deprecated iOS 6.

When does UIViewController's viewDidUnload automatically get called? Yes I know, when the view unloads. But when does that happen automatically? How can I do it manually? Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you issue a memory warning in the simulator (look in the menu), this will get called for any view controller attached to a view that is not visible.

That's because view controllers by default are registered for memory warning notifications, and any view that is not currently being used will be unloaded by the view controller - the viewDidUnload method is there so that you can clean up anything else you would like, to save extra memory (or if you've retained some IBOutlets to help free up memory that would otherwise be released by the view being unloaded).

Generally any IBOutlets you release in dealloc, should also be released (and references set to nil) in this method.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...