Ipad从自定义相册设备问题中获取图像 [英] Ipad Get Images from custom album Device Issue

查看:160
本文介绍了Ipad从自定义相册设备问题中获取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ipad设备中有自定义文件夹。我使用此代码从自定义相册中获取图像:

Am having a Custom folder in my ipad device. Am using this code to get image from Custom album:

self.assetGroups = [[NSMutableArray alloc] init];
// Group enumerator Block
dispatch_async(dispatch_get_main_queue(), ^
{
   void (^assetGroupEnumerator)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop)
   {
       if (group == nil) {
           return;
       }
       if ([[group valueForProperty:ALAssetsGroupPropertyName] isEqualToString:@"Ganesh"]) {
           [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:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
       [alert show];
       [alert release];
   };

    // Enumerate Albums
    self.library = [[ALAssetsLibrary alloc] init];
    [library enumerateGroupsWithTypes:ALAssetsGroupAll
    usingBlock:assetGroupEnumerator
    failureBlock:assetGroupEnumberatorFailure];
});

要从我的自定义文件夹中检索所有图像,我使用的是:

To retrieve all the images from my custom folder I am using this:

(void)loadImages {
    ALAssetsGroup *assetGroup = [self.assetGroups objectAtIndex:0];

    NSLog(@"asserts group %@",self.assetGroups);
    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]];
     NSLog(@"image name%@",img);
     [arrayOfImage addObject:img];
     NSLog(@"arrayOfImage %@",arrayOfImage);
     // [imageToAnimate setImage:img];
     }];
}

当我使用模拟器但不在设备中运行时它工作正常:它执行失败并说没有专辑可用。

its working fine when i am running with simulator but not in device: it executes Failure block and Says No Album Available.

推荐答案

它的工作正常。我已经关闭了我的位置服务,因为现在无法访问我的媒体它工作正常。

Its works fine. I have switched Off my location service due to this am not able to access my media now it works fine.

这篇关于Ipad从自定义相册设备问题中获取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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