http://blog.csdn.net/gdutxzy/article/details/44126437
-(void)loadgif
{
NSMutableArray *Imgarr = [NSMutableArray array];
libary = [[ALAssetsLibrary alloc]init];
// ALAssetsGroupAll 取得全部类型
[libary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if(group != Nil)
{
//2.再通告文件夹遍历其中的资源文件
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
//index就是他的位置
//ALAsset 的这个result 就是我们要的图片
//两种情况
//单选的话,这个界面是自带的
//多选的话,没有提供界面,但是提供了照片的资源,我们可以创建一个tableview来弄
//这个地方我们一般是找一个model或者数组来接受
//用数组保存起来
if(result != nil)
{
// 照片
if ([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto])
{
NSString *fileName = [[result defaultRepresentation] filename];
int64_t fileSize = [[result defaultRepresentation] size];
//取得缩略图
CGImageRef cmimg = [result thumbnail];
UIImage * img = [UIImage imageWithCGImage:cmimg];
YC_PlayMD *model = [[YC_PlayMD alloc]init];
model.path = fileName;
model.fullPath = fileName;
model.length = [NSNumber numberWithFloat:fileSize/1024.0/1024.0];
model.SfileType = 1;
model.capImg = img;
model.selected = [NSNumber numberWithInt:0];
model.curAsset = result;
if([fileName hasSuffix:@".GIF"])
{
[Imgarr addObject:model];
}
}
}
}];
self.imgdataSource = [NSMutableArray arrayWithArray:Imgarr];
[self.giftableView reloadData];
}
} failureBlock:^(NSError *error) {
}];
}
网友评论