Reputation: 442
I have custom control like tabbar which displays many controllers some of them also have my tabbar with other controllers, so, my app uses lots of memory because every controller is stored in memory. So I want to unload invisible controller, but I not found any method for unloading UIViewController. How can I do it?
PS. I can not use UITabBarController, really can't.
Upvotes: 5
Views: 4851
Reputation: 18865
I know it's an old thread but might be usefull for someone.
You can unload viewControllers view by calling:
[viewControllerWhoseViewYouWantToUnload didReceiveMemoryWarning];
Upvotes: 1
Reputation: 38475
You don't. UIViewControllers don't get unloaded in low memory, just their views do.
This happens in didReceiveMemoryWarning
on your own view controllers and gets called automatically when a low memory warning occurs.
Override this and unload anything that can be re-created in viewDidLoad
.
Upvotes: 1
Reputation: 22334
Remove the view controllers view from it's superview and release the controller. Job done.
Upvotes: 1