Search code examples
iosimagealassetslibrary

How do I display the images in a custom album in my iOS App


I have created a custom album with using the below code

(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    <--other code stuffs here-->
    <--selectedImage is the UIImage from Camera or from gallery-->

    [self.library saveImage:selectedImage toAlbum:@"My Album" withCompletionBlock:^(NSError *error)
    {
        if (error!=nil)
        {
            NSLog(@"Big error: %@", [error description]);
        }
    }];
    <--other code stuffs here-->
}

Now I want to display these saved images in my application.

How do I access these images, and create a gallery in my APP.

Thanks,

Sujith


Solution

  • The method you want is the ALAssetsLibrary method addAssetsGroupAlbumWithName:resultBlock:failureBlock: which is detailed in the docs here: http://developer.apple.com/library/ios/#documentation/AssetsLibrary/Reference/ALAssetsLibrary_Class/Reference/Reference.html#//apple_ref/occ/cl/ALAssetsLibrary

    It was introduced in iOS 5 and has not since been deprecated, so I'm not quite sure what the issue is if it's not working for you. You may have to update or repost the question if you are having trouble with it.