It took me more than 2 hours to fix this “Memory warning” issue with the UIImagePickerController. My Application worked very well in the simulator. On the Phone i got this Memory warning every time i took a picture with the camera. The picker returned an UIImage = nil. This is my code:
-(void)viewDidLoad { self.imgPicker = [[UIImagePickerController alloc] init]; self.imgPicker.allowsImageEditing = YES; self.imgPicker.delegate = self; self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; } -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { dispimage = [[info objectForKey:UIImagePickerControllerOriginalImage]retain]; [picker dismissModalViewControllerAnimated:YES]; } -(IBAction)open { if(self.imgPicker == nil) { self.imgPicker = [[UIImagePickerController alloc] init]; self.imgPicker.allowsImageEditing = YES; self.imgPicker.delegate = self; self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; } [self presentModalViewController:self.imagePicker animated:YES]; [self.imagePicker release]; } -(IBAction) print { if(dispimage != nil) { imageView.image=dispimage; } };
And the solution? I’ve just to closed all open applications, which where a lot! It seems to me it is also a memory leak bug in current 4.0.x releases. Hopefully it will be fixed with the next iOS release.
So long, i’m going to bed now.
Tagged: apple, BlogIt, Bug, Problem, UIImagePickerController, zero-one



