如何在iOS应用程序中的自定义相册中显示图像

时间:2013-06-07 16:18:32

标签: ios image alassetslibrary

我使用以下代码创建了自定义相册

(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-->
}

现在我想在我的应用程序中显示这些保存的图像。

如何访问这些图像,并在我的APP中创建图库。

谢谢,

Sujith

1 个答案:

答案 0 :(得分:2)

您需要的方法是ALAssetsLibrary方法addAssetsGroupAlbumWithName:resultBlock:failureBlock:详情请参见此处的文档:http://developer.apple.com/library/ios/#documentation/AssetsLibrary/Reference/ALAssetsLibrary_Class/Reference/Reference.html#//apple_ref/occ/cl/ALAssetsLibrary

它是在iOS 5中引入的,并且此后一直没有被弃用,所以我不太确定如果它不适合你的问题是什么。如果您遇到问题,可能需要更新或重新发布问题。