Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
351 views
in Technique[技术] by (71.8m points)

iphone - Received memory warning. Level=1 when showing a UIImagePickerController

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 :)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...