我正在使用UICollectionView
来显示从设备照片库加载的图片。我正在使用资源库来加载图像。当我滚动UICollectionView
时,图像正在改变它们在集合视图中的位置(不重复)。因此,当我点击图像时,会加载不同的图像。有什么帮助吗?
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = @"Cell";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
UIImageView *GalleryImageView = (UIImageView *)[cell viewWithTag:100];
url=@"";
Document* doc = [galleryImages objectAtIndex:indexPath.row];
GalleryImageView.contentMode = UIViewContentModeScaleAspectFill;
url = doc.path;
NSLog(@"%@",url);
NSURL *referenceURL = [NSURL URLWithString:url];
__block UIImage *returnValue = nil;
[library assetForURL:referenceURL resultBlock:^(ALAsset *asset)
{
returnValue = [UIImage imageWithCGImage:[[asset defaultRepresentation] fullScreenImage]];
GalleryImageView.image = returnValue;
returnValue = nil;
documentID= [dbutil getDocumentIDbyPath:url];
GalleryImageView.tag = documentID;
}
failureBlock:^(NSError *error)
{
NSLog(@"error : %@", error);
}];
return cell;
}