如果你能试试
NSMutableArray *assetGroups = [[NSMutableArray alloc] init];
void (^assetGroupEnumerator) (ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop)
{
if(group != nil)
{
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop)
{
//ALAssetRepresentation holds all the information about the asset being accessed.
if(result)
{
ALAssetRepresentation *representation = [result defaultRepresentation];
if (representation !=nil)
{
UIImage *PhotoThumbnail = [UIImage imageWithCGImage:[result thumbnail]];
[fetchedThumbnails addObject:PhotoThumbnail];
UIImage * latestPhoto = [UIImage imageWithCGImage:[result thumbnail]];
[fetchedImages addObject:latestPhoto];
}
}
}];
[assetGroups addObject:group];
}
galleryImagesCV.hidden=NO;
[galleryImagesCV reloadData];
};
assetGroups = [[NSMutableArray alloc] init];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
NSUInteger groupTypes = ALAssetsGroupSavedPhotos;
[library enumerateGroupsWithTypes:groupTypes usingBlock:assetGroupEnumerator failureBlock:^(NSError *error)
{
NSLog(@"A problem occurred");
}];
导入 AssetsLibrary/AssetsLibrary.h
这将为您提供数组中图库中的所有图像。您可以在自定义视图中显示这些并选择/交换等。
希望能帮助到你