7

我使用枚举所有资产组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

编辑:正如我测试的那样,它总是最后一个,使用这个枚举。但我不确定这是否是规则,是否有任何我遗漏的参考资料?

4

2 回答 2

14

ALAssetsGroupSavedPhotos要在枚举资产库时从相机胶卷使用中获取照片:

[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos
                       usingBlock:enumerate
                     failureBlock:nil];

要检测您当前获得的组:

if ([[group valueForProperty:@"ALAssetsGroupPropertyType"] intValue] == ALAssetsGroupSavedPhotos)
{
    NSLog(@"Camera roll");
}
于 2013-03-22T12:22:57.763 回答
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];
于 2014-04-23T09:59:59.560 回答