views:

45

answers:

1

Hello all

When I receive a memory warning in my navigation based iPhone App the background image disappears in the previously allocated navigation controllers.

The background image is set as the background property of a UIView. This view is then added to the main window of the App delegate:

UIView *backgroundView = [[UIView alloc] initWithFrame: window.frame];

backgroundView.backgroundColor = [UIColor colorWithPatternImage:[[Utilities sharedManager] getImageWithName:@"Hintergrund2"]]; backgroundView.tag = 56789; [window addSubview:backgroundView]; [backgroundView release];

[window addSubview:[navigationController view]];

[window makeKeyAndVisible];

After I received the memory warning message and pressed the back button of the navigation controller the previous navigation controller shows up the normal Apple gray background. I have to navigate back to my home screen and navigate forward to "reset" the background image.

Can anyone tell me why the background disappears? It is not because of the image, when I set the background to a standard UIColor like blackColor the background (color) also disappears.

Thank you in advance for your help!

regards

Phil

+1  A: 

It is undefined what the OS does with stuff added directly to the main UIWindow in case of low memory situations.

Maybe consider using a simple UIViewController for the background? You will then at least get callbacks when there is a low memory situation.

St3fan
thanks for your advice. I did the following without success:
Philipp Noggler
navigationController.view.backgroundColor = [UIColor colorWithPatternImage:[[Utilities sharedManager] getImageWithName:@"Hintergrund2"]];
Philipp Noggler