Save image in frame using UIImageWriteToSavedPhotosAlbum

I try to save a photo using the button for the camera roll after the user captured the photo using the camera, but I don’t know why my photo is not saved in the photo library!

Here is my code:

-(IBAction)savePhoto{ UIImageWriteToSavedPhotosAlbum(img.image,nil, nil, nil); } -(IBAction)takePic { ipc = [[UIImagePickerController alloc]init]; ipc.delegate = self; ipc.sourceType = UIImagePickerControllerSourceTypeCamera; [self presentModalViewController:ipc animated:YES]; } - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { img.image = [[info objectForKey:UIImagePickerControllerOriginalImage]retain]; [[picker parentViewController]dismissModalViewControllerAnimated:YES]; [picker release]; } 

The ipc variable name is UIImagePickerController , and img is UIIMageView .

what's my problem

+4
source share
1 answer

First make sure you call savePhoto . You can then add a statement to verify that the image is not nil:

 - (IBAction) savePhoto { NSParameterAssert(img.image); UIImageWriteToSavedPhotosAlbum(img.image, nil, nil, nil); } 
+4
source

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


All Articles