Reputation: 47348
I'm thinking of a way to respond to memory warnings generated by iOS. I got one "expensive" tab bar controller that is a good candidate for de-allocation in response to memory warning.
How would I go about marking a controller managed by UITabBar "free for deletion", but allow the user to re-initialize the controller if a user re-selects the proper UITabBar tab?
Will UITabBar take care of re-initializing a controller that was deallocated, or will this involve some sort of lazy initialization?
Do I need to write custom code for what happens when a tab is selected and the controller is nil?
Upvotes: 0
Views: 532
Reputation: 359
UITabBarController auto manage its allocation and deallocation.
For example, when you add a UIViewController to it, the tabbarcontroller will NOT load your view (calling viewDidLoad), it will load only your class (init method). Then you can do all the heavy work on viewDidLoad.
When it receive an warning notification, TabbarController will release all your views, except the current one and will reload when user go back to a released tab.
-- sry for the bad english there.
Upvotes: 3