滚动时,所有项目都被复制了。我使用GCCategoryCell作为可重用的单元标识符。
CollectionCell *cell=[collectionView1 dequeueReusableCellWithReuseIdentifier:@"GCCategoryCell" forIndexPath:indexPath];
我在数组中只有5个项目,我使用numberOfItemsInSection返回。当我应用滚动时,图像会重复。
- (UICollectionViewCell *)collectionView:(__unused UICollectionView *)collectionViewIn cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
SmsContent *objSms=[arrContent objectAtIndex:indexPath.row];
NSString *strImagePath = [NSString stringWithFormat:@"s3-us-west-2.amazonaws.com/smsgupshup/%@/%@";,
objSms.strSmsId, objSms.strImageName];
[cell.photoView setImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:strImagePath]]]];
[cell.photoView setTag:indexPath.row];
[cell.btnPhoto setTag:indexPath.row];
return cell;
}