我必须在 UIcollectionView 中显示很多图像,可能大于 200。图像尺寸很大。但是那里存在严重的性能问题。滚动变慢,有时会崩溃。我不知道在这种情况下优化的最佳方法是什么。我有一个包含 UIImageView 的保管单元,我在方法中加载图像:
- (UICollectionViewCell *)collectionView:(UICollectionView *)CollectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
PhotoCollectionCell *cell = [CollectionView dequeueReusableCellWithReuseIdentifier:kCellReuseIdentifier forIndexPath:indexPath];
if(cell==nil){
NSLog(@"cell is nil");
}
NSLog(@"%@",NSStringFromCGRect(cell.frame));
ImagesDb *imageObj = [folderImagesArr objectAtIndex:indexPath.row];
ImagesDataDb *imageData = imageObj.data;
cell.cellImage.image = imageData.orignalImage;
UILabel *titleLabel = (UILabel *)[cell viewWithTag:100];
[titleLabel setText:[NSString stringWithFormat:@"%d",indexPath.row]];
}
return cell;
}