我使用ALAssetsLibrary
这是代码:
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
void (^enumerate)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop)
{
if (group == nil)
{
// enumerated all albums..
}
// I hot to check if group is Camera Roll ?
};
[library enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:enumerate
failureBlock:nil];
如何检查当前枚举的是 CameraRoll ?
编辑:正如我测试的那样,它始终是最后一个,使用此枚举。但我不确定这是否是规则,是否有任何我错过的参考?
答案 0 :(得分:14)
要在枚举资产库时使用ALAssetsGroupSavedPhotos
从相机胶卷获取照片:
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos
usingBlock:enumerate
failureBlock:nil];
要检测您当前获得的群组:
if ([[group valueForProperty:@"ALAssetsGroupPropertyType"] intValue] == ALAssetsGroupSavedPhotos)
{
NSLog(@"Camera roll");
}
答案 1 :(得分:3)
imageArray = [[NSArray alloc] init];
NSMutableArray*mutableArray =[[NSMutableArray alloc]init];
NSMutableArray* assetURLDictionaries = [[NSMutableArray alloc] init];
ALAssetsLibrary*library = [[ALAssetsLibrary alloc] init];
void (^enumerate)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop)
{
if ([[group valueForProperty:@"ALAssetsGroupPropertyType"] intValue] == ALAssetsGroupSavedPhotos)
{
NSLog(@"Camera roll");
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
ALAssetRepresentation *rep = [result defaultRepresentation];
NSLog(@"Asset Name ----> %@",rep.filename);
}];
}
// I hot to check if group is Camera Roll ?
};
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos
usingBlock:enumerate
failureBlock:nil];