Received memory warning. Level=1 when showing a UIImagePickerController

wgpubs picture wgpubs · Jun 23, 2010 · Viewed 41.3k times · Source

This is driving me crazy!!!

I'm getting a "Received memory warning. Level=1" whenever I attempt to show a UIImagePickerController with a sourceType = UIImagePickerControllerSourceTypeCamera.

Here is the code from my viewDidLoad where I set things up:

    - (void)viewDidLoad {

    [super viewDidLoad];

    // Set card table green felt background
    self.view.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"green_felt_bg.jpg"]];


    // Init UIImagePickerController
    // Instantiate a UIImagePickerController for use throughout app and set delegate
    self.playerImagePicker = [[UIImagePickerController alloc] init];
    self.playerImagePicker.delegate = self;
    self.playerImagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
}

And here is how I present it modally ..

- (IBAction) addPlayers: (id)sender{
[self presentModalViewController:self.playerImagePicker animated:YES];

}

The result ... UIImagePicker starts to show and then boom ... I get the memory warning ... EVERY TIME! Interestingly enough, if I switch to sourceType = UIImagePickerControllerSourceTypePhotoLibrary ... everything works fine.

What in the heck am I missing or doing wrong? All I want to do is show the camera, take and save a picture.

FYI - I'm testing on my 3GS device.

Thanks to anyone who can help :)

Answer

progrmr picture progrmr · Jun 23, 2010

This is very common. As long as you handle the memory warning without crashing and have enough space to keep going, don't let it drive you crazy.