我们尝试将相册中的图像异步加载到不同的UIImageView。但现在,在大延迟之后,所有图像都会加载在一起。
- (void)loadAllAssetWithHandler:(void (^)(ALAsset *))hanlderAssetDidLoad
{
ALAssetsLibraryAccessFailureBlock blockFailure = ^(NSError *error){
NSLog(@"ERROR = %@", error.description);
};
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
void (^assetGroupEnumerator)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop)
{
if (group == nil) {
return;
}
if([[group valueForProperty:ALAssetsGroupPropertyName] isEqualToString: @"album"])
{
[group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop)
{
if(asset == nil) {
return;
}
hanlderAssetLoad(asset);
}];
return;
}
};
// Enumerate Albums
[library enumerateGroupsWithTypes: ALAssetsGroupAll
usingBlock: assetGroupEnumerator
failureBlock: blockFailure];
[library release];
}
和
[self loadAllAssetsWithHandlert:^(ALAsset *asset) {
UIImageView *imageView = [self nextImageVIew];
imageView.image = [UIImage imageWithCGImage: asset.defaultRepresentation.fullResolutionImage]; //or thumbnail
}];
那么,我们如何将图片轮流上传到UIImageView(每次上传后立即)?