我有一个UITableView,我在每个自定义UITableViewCell中放置一个UIScrollView。就像aribnb一样。我有一些UIImage来显示来自互联网的一些图像,一切正常。 但是当我下载图像并希望在tableViewCell中再次显示它们时,我使用以下代码,我发现显示新图像和右图像以更改旧图像并重复使用图像,差不多2或3秒。
这是我的tableviewcell委托
static NSString *ReusedIdentifier = @"mainDailyTableViewCell";
ILDailyTableViewCell *cell = (ILDailyTableViewCell *)[tableView dequeueReusableCellWithIdentifier:ReusedIdentifier];
if (cell == nil)
{
cell = [[ILDailyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:ReusedIdentifier
viewType:VIEWTYPE_DETAIL];
[cell.itemScrollView setItemDelegate:self];
}
if (indexPath.row < [_contentList count])
{
ILDailyItemInfo *preRowDailayItem = [_contentList objectAtIndex:indexPath.row];
NSMutableArray *cellItemList = [[NSMutableArray alloc] init];
for (id item in preRowDailayItem.dealList)
[cellItemList addObject:item];
if ([cellItemList count] == 0)
cellItemList = nil;
[cell setCellItems:cellItemList];
}
else
[cell setCellItems:nil];
return cell;
这是我的前项目视图集图像方法
- (void)showOutMainImageInfo:(ILDailyItemInfo *)itemInfo {
UIImage *showImage = itemInfo.image;
__block ILDailyItemView *weakSelf = self;
if (showImage == nil)
{
[[SDWebImageManager sharedManager] downloadImageWithURL:[NSURL URLWithString:imageUrl] options:SDWebImageRetryFailed progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
itemInfo.image = image;
[_dailyItemImageView showWithMain:[ILResizeImage resizeImage:image withRect:CGRectMake(0, 0, weakSelf.itemMainImageView.frame.size.width, weakSelf.itemMainImageView.frame.size.height)]
bottomImage:[[ILResizeImage resizeImage:image withRect:CGRectMake(0, 0, weakSelf.bottomImageView.frame.size.width, weakSelf.bottomImageView.frame.size.height)] applyExtraLightEffect]];
}];
}
else
{
[_dailyItemImageView showWithMain:[ILResizeImage resizeImage:showImage withRect:CGRectMake(0, 0, weakSelf.itemMainImageView.frame.size.width, weakSelf.itemMainImageView.frame.size.height)]
bottomImage:[[ILResizeImage resizeImage:showImage withRect:CGRectMake(0, 0, weakSelf.bottomImageView.frame.size.width, weakSelf.bottomImageView.frame.size.height)] applyExtraLightEffect]];
}
}
,这是我的每日项目图片视图绘制方法
- (无效)的drawRect:(的CGRect)RECT {
if (_mainImage)
{
[_mainImage drawInRect:_mainImageFrame];
}
if (_bottomImage)
{
[_bottomImage drawInRect:_bottomImageFrame];
}
}