如何访问我在相机应用中保存的相册? [英] How do I get access to the album I saved photos like in camera app?

查看:219
本文介绍了如何访问我在相机应用中保存的相册?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用代码在我的应用程式中将照片保存到我的自定义相册中

I have saved photos to my customised album in my app using code

[library saveImage:self.capturedImg toAlbum:@"FunCam" withCompletionBlock:^(NSError *error) {
    if (error!=nil) {
        NSLog(@"Big error: %@", [error description]);
    }
}];

现在,当用户点击某个按钮并显示在视图中时,喜欢相机应用程式(iPhone上的预设应用程式)显示

Now I want to retrive all photos saved to that album when user click some button and show them in view like camera app (the default app on iphone) shows

请帮我怎么办?

提前感谢

推荐答案

尝试以下方法...

-(void)loadNewLibraryImages
{
    self.assetGroups = [[NSMutableArray alloc] init];
    // Group enumerator Block
    dispatch_async(dispatch_get_main_queue(), ^
                   {    
                       void (^assetGroupEnumerator)(struct ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop) 
                       {
                           if (group == nil) 
                           {
                               return;
                           }
                           if ([[group valueForProperty:ALAssetsGroupPropertyName] isEqualToString:@"YOUR ALBUM NAME"]) {
                               [self.assetGroups addObject:group];                             
                               [self loadImages];
                               return;
                           }                           

                           if (stop) {
                               return;
                           }

                       };

                       // Group Enumerator Failure Block
                       void (^assetGroupEnumberatorFailure)(NSError *) = ^(NSError *error) {

                           UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"ERROR" message:[NSString stringWithFormat:@"No Albums Available"] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
                           [alert show];
                           [alert release];
                       };   

                       // Enumerate Albums
                       ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];        
                       [library enumerateGroupsWithTypes:ALAssetsGroupAll
                                              usingBlock:assetGroupEnumerator 
                                            failureBlock:assetGroupEnumberatorFailure];


                   });


}

-(void)loadImages
{   
    //for (ALAssetsGroup *assetGroup in self.assetGroups) {
//  for (int i = 0; i<[self.assetGroups count]; i++) {

        ALAssetsGroup *assetGroup = [self.assetGroups objectAtIndex:0];
        NSLog(@"ALBUM NAME:;%@",[assetGroup valueForProperty:ALAssetsGroupPropertyName]);

        [assetGroup enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) 
         {         
         if(result == nil) 
         {
         return;
         }
            UIImage *img = [UIImage imageWithCGImage:[[result defaultRepresentation] fullScreenImage] scale:1.0 orientation:(UIImageOrientation)[[result valueForProperty:@"ALAssetPropertyOrientation"] intValue]];         

         }];  

//  }
}

希望他们会帮助。 ...

hope they will help....

这篇关于如何访问我在相机应用中保存的相册?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆