Question

I understand that I can't programmatically delete photos from my app . Because Apple writes that we can only add photos

To save a still image to the user’s Saved Photos album, use the UIImageWriteToSavedPhotosAlbum function. To save a movie to the user’s Saved Photos album, use the UISaveVideoAtPathToSavedPhotosAlbum function.

But I find project that have photos in project, so I can delete photos from this app by clicking delete icon (but still it crashes then =) ) project

And now I see only two ways:

  1. Save photos in my project folder and then I can do with it what I want. Can I do it? I think no =(
  2. Open standart Photos app from my app (open with...) but I read some threads about it, and I understood that it's impossible. That's right?
  3. Update! I written this point below. Can I create links in my app to photos in Photo Library? And then, if I want to delete photo from my app, I will delete link, so i will not see photo in my app, but it still stay in Photo Library. Does it possible?

So after all my searching I haven't found a solution. Are their some ways to solve my problem?

Was it helpful?

Solution

On Youtube I find next video and I understand that I can save photo to document directory. It was next code in video

UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
NSData *data = UIImagePNGRepresentation (image);
NSString *myGrabbedImage = @"myGrabbedImage.png";
NSArray *path = NSSearchPathForDirectoriesInDomainns (NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [path objectAtIndex:0];
NSString *fullPathToFile = [documentDirectory stringByAppendingPathComponent:myGrabbedImage];
[data writeToFile:fullPathToFile atomically:YES];

So I understand that is simple to save photo from Photo Library to my array, and then open photos from array. And I will can than simply delete photos by remove them from my array. Ok, but now I have 2 questions:

  1. How I can distinguish photos that i will save in my array? If I will allocate same photo in Photo Library it will be save some times - it's not good.
  2. So it will be work only with PNG images?

PS Sorry, if this questions very newbiest, but my brain exploded after allday searching.

OTHER TIPS

It is possible to take a photo of the camera and get a UIImage and write it to a folder that your app owns. You can't write it to your apps space because you only have read access to it. The folder of choice for your problem would be the Documents folder. Have a look here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top