1) 使用enumerateGroupsWithTypes:usingBlock:failureBlock: 枚举 ALAsset 库中的组。
2) 检查群组的ALAssetsGroupPropertyName 是否与您使用valueForProperty: 搜索的专辑名称相同。
例如
NSString * groupName = [group valueForProperty:ALAssetsGroupPropertyName];
[groupName localizedCaseInsensitiveCompare:albumName] == NSOrderedSame
3) 找到组后,使用enumerateAssetsUsingBlock: 枚举其中的资产。
4) 对于每个ALAsset,检索它是defaultRepresentation,然后是fullScreenImage。
例如
ALAssetRepresentation * assetRepresentation = [asset defaultRepresentation];
CGImageRef imageRef = [assetRepresentation fullScreenImage];
5) 对于每个ALAsset,使用ALAssetPropertyOrientation 和valueForProperty: 检索它是UIImageOrientation。
例如
UIImageOrientation imageOrientation = [[asset valueForProperty:ALAssetPropertyOrientation] intValue];
6) 对于每个ALAsset alloc/init 一个UIImage 使用imageWithCGImage:scale:orientation:。然后,插入您在第 4 步和第 5 步中检索到的fullScreenImage 和UIImageOrientation。
例如
UIImage * image = [UIImage imageWithCGImage:imageRef scale:1.0f orientation:imageOrientation];
7) 分配/初始化 UIImage 后,将其添加到 NSMutableArray。
8) 枚举完成后,将图像呈现给用户。
注意:
用于枚举组和资产的两种方法都是异步的,这意味着它们将立即返回。