【发布时间】:2015-03-05 14:01:53
【问题描述】:
我有一个带有自定义单元格的 UICollectionView,该单元格有一些标签和一个 UIImageView,数据是从一些 Json 下载的,然后我填充我的单元格,问题是当我再次向上滚动时,某些单元格的图像会发生一秒钟的变化进入错误的(另一种产品),然后他们再次重置为正确的。我正在为 UIImageView 使用延迟加载和以下库 https://github.com/nicklockwood/AsyncImageView 有没有人遇到我同样的问题? 我填充单元格的代码如下:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
[self performSelector:@selector(test) withObject:nil];
cell.backgroundColor = [UIColor whiteColor];
// Configure the cell
FidelityProducts *item = _feedItems[indexPath.row];
//load the image
urlImg = [NSURL URLWithString:item.urlImg];
cell.img.showActivityIndicator = true;
cell.img.imageURL = urlImg;
cell.titolo.text = item.nomeProdotto;
cell.codice.text = item.codice;
cell.prezzo.text = item.prezzo;
UIView *bottomBorder = [[UIView alloc] initWithFrame:CGRectMake(0, cell.frame.size.height - 1, cell.frame.size.width, 1)];
bottomBorder.backgroundColor = [UIColor redColor];
[cell.contentView addSubview:bottomBorder];
return cell;
}
【问题讨论】:
标签: ios objective-c uicollectionview