IOS:集合视图图像位置变化

时间:2013-08-13 07:05:52

标签: iphone ios uicollectionview uicollectionviewcell

我正在使用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;
    }

0 个答案:

没有答案