【发布时间】:2015-08-25 09:53:43
【问题描述】:
如何在 uicollectionview 中使用惰性显示圆形进度条 正在加载图片。
ClothCell weakCell = (ClothCell )[collectionView dequeueReusableCellWithReuseIdentifier:@"ClothesCell" forIndexPath:indexPath];
weakCell.tag=indexPath.item;
weakCell.contentView.opaque = NO;
weakCell.contentView.clipsToBounds = YES;
weakCell.opaque = YES;
weakCell.clipsToBounds = YES;
weakCell.contentView.backgroundColor = [UIColor clearColor];
Clothes *clothes = [self.arrayClothes objectAtIndex:indexPath.item];
[weakCell.imageViewCloth setImage:nil];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
// dispatch_async(dispatch_get_main_queue(), ^{
[self.manager downloadWithURL:clothes.url options:SDWebImageLowPriority progress:^(NSUInteger receivedSize, long long expectedSize) {
CGFloat domandeFloat = [[NSNumber numberWithInteger:receivedSize]floatValue];
CGFloat corretteFloat = [[NSNumber numberWithLongLong:expectedSize] floatValue];
float currentProgress = domandeFloat/corretteFloat;
[weakCell.circleProgressBar setProgress:currentProgress animated:YES];
} completed:^(UIImage image, NSError error, SDImageCacheType cacheType, BOOL finished) {
if(image){
weakCell.imageViewCloth.image=image;
weakCell.imageViewCloth.clipsToBounds = YES;
weakCell.imageViewCloth.layer.borderWidth = 1.0;
weakCell.imageViewCloth.layer.borderColor = [UIColor blackColor].CGColor;
[weakCell.circleProgressBar setProgress:1 animated:YES];
}
}];
});
//[weakCell.imageViewCloth setImageWithURL:clothes.url];
return weakCell;
}
我已经尝试过这段代码,但当我向上和向下滚动时遇到了问题。它 使用相同的单元格。
【问题讨论】:
标签: ios iphone progress-bar lazy-loading uicollectionviewcell