5

how to save the image on iPhone, in the gallery, in applications such as "wallpaper " ?

Hi :) i create app with wallpapers :) but i dont know how to save my images in gallery :( Help me please

  • Other people have asked similar questions in Stack Overflow as a quick search would show you. You can find a good example here: http://stackoverflow.com/questions/6812634/how-to-take-picture-from-camera-saved-in-photo-gallery-by-programmatically. If those did not work for you, please explain why it didn't in your question. – Breno Gazzola Sep 26 '12 at 23:36
  • I have a plist file, which is a dictionary and an array of images. I need that I was staying at a particular picture, pressed the button "save" and it is saved in the gallery :) – Родион Рябушин Sep 27 '12 at 10:05

1 Answers1

32

To save an image you can use this line of code:

    UIImage *image = [UIImage imageNamed:"someImage.png"];
    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);

There are also ways to check when the image is done saving, the full documentation can be found here: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIKitFunctionReference/Reference/reference.html

On newer iOS versions, it is required by Apple that in your info.plist you add a usage descriptor for the key Privacy - Photo Library Additions Usage Description. (NSPhotoLibraryAddUsageDescription)

Albert Renshaw
  • 17,282
  • 18
  • 107
  • 195
shabbirv
  • 8,958
  • 4
  • 33
  • 34
  • From Apple's website: UIImageWriteToSavedPhotosAlbum Adds the specified image to the user’s Camera Roll album. – Simon Germain Sep 26 '12 at 20:05
  • THNX :) but what to press to save it? to prescribe what that button? or both? :) – Родион Рябушин Sep 26 '12 at 20:49
  • Shabzco :) rly THNX for YOU :) I ordered what you told me :) using (IBAсtion), but it is for individual pictures :) with individual names. I have a plist file, which is a dictionary and an array of images. I need that I was staying at a particular picture, pressed the button "save" and it is saved in the gallery :) – Родион Рябушин Sep 26 '12 at 21:40
  • The other way, in case you want to save image to your specific album directory, could be to use image to NSdata, and then write the data to specified path. – khunshan Mar 18 '14 at 08:28
  • You can also add 'Privacy - Photo Library Additions Usage Description' key with '$(PRODUCT_NAME) photo use' value into info.plist for enable photo library from you app. – Alessandro Pirovano May 02 '18 at 10:38