I’m creating an app using a UITabBarController as the main form of navigation, having never done this before I’ve ran into a little bit of an issue.
On two of the four tabs, the view controllers held drill down using a standard navigation controller and browse through categories and then into items, the categories and items have quite a few images.
After a few minutes of using my app (down to the item stage where a scrollview of 4 320×460 images is used) i get..
Received memory warning. Level=1
This then deallocate’s all of the view’s currently held in my UITabBarController, and when I click the tabs, i am presented with only white screens.
When using images, I am trying to use..
UIImageView *imageView = [[[UIImageView alloc] init] autorelease];
[imageView setImage:[UIImage imageNamed:@"image"]];
[self.view addSubview:imageView];
..as much as possible, as far as i’m aware, that is ‘memory managed’, and should dealloc correctly.
The memory issue I believe is merely being caused by 4 large images being loaded into memory, this is a requirement of my app. The tab’s dissapearing isn’t :/
Any ideas/guidance?
This is by design. When your app receives a memory warning, all view controllers that are not currently visible will unload their views. You have to be prepared for that. When the user reopens a tab that was unloaded, the view controller reloads the view and calls
-viewDidLoadagain where you should do your view setup.