Search code examples
iphoneobjective-ciosios5

how to save the image on iPhone, in the gallery?


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


Solution

  • 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)