Reputation: 466
I have a Tab Bar Controller with two views (and two buttons at the bottom to match). When I am in the second view, and press the first button, I want to not simply hide the second view, but unload it entirely until it is accessed again.
How, and where (from which end of the view-changing process-- in the tab bar's firstButtonPressed method, in the first view's ViewWillAppear method, etc.) should I do this?
Upvotes: 1
Views: 438
Reputation: 2822
Is this to save memory, or for a UX reason? If the first is the case, and you are nil-ing out non-weak IBOutlet properties on viewDidUnload, you are good to go. Whenever the OS decides it needs more memory, it will start dumping out views that are not on-screen.
If the second is the case, do what you need in the viewDidDisappear method of the class you want to trash (i.e. remove from superviews and nil as needed).
Upvotes: 2