如果显示所有项目,如何阻止UICollectionview的cellForItemAtIndexPath调用?

时间:2016-02-15 09:25:07

标签: ios objective-c uicollectionview

滚动时,所有项目都被复制了。我使用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;
}

0 个答案:

没有答案