UIImagePickerController Camera Received Memory Warning

When I enter the UIImagePickerController, I get a memory warning message and I donโ€™t know how to fix it.

this is my code:

-(IBAction)addImageCamera:(id)sender { if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { pickerImgCamera.sourceType = UIImagePickerControllerSourceTypeCamera; cameraView.image=[img imageFromMainBundleFile:@"frameCam.png"]; pickerImgCamera.cameraOverlayView=cameraView; [self.navigationController presentModalViewController:pickerImgCamera animated:NO]; } else { UIAlertView*alert=[[UIAlertView alloc] initWithTitle:@"Oops" message:@"Camera not found" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; alert=nil; } } - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) { [self dismissModalViewControllerAnimated:YES]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); }); } [photoImage setImage:image]; } 

Note: a memory warning appears on iphone and ipad.

+4
source share
2 answers

In my experience, the iPhone camera often triggers memory alerts, especially on older devices. This is more likely to happen when you are debugging - the trick processes a warning and gets rid of unnecessary things.

0
source

if image quality is not so important in your application, then set the videoQuality uiimagepickercontroller parameter to UIImagePickerControllerQualityTypeLow. This will reduce the memory warning in the application.

-2
source

Source: https://habr.com/ru/post/1439079/


All Articles