【发布时间】:2018-01-30 07:11:40
【问题描述】:
我的项目中有一个集合视图,其中包含来自 Web 服务的大量数据。当我垂直滚动集合视图时,它不会平滑滚动。
我使用SDWebImage 异步加载图像。
这里是cellForItemAtIndexPath的代码:
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
CategoryListCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CategoryListCell" forIndexPath:indexPath];
cell.movName.text = [nameArray objectAtIndex:indexPath.item];
num = [[numArray objectAtIndex:indexPath.item]integerValue];
cell.itemNo.text = [NSString stringWithFormat:@"%ld", (long)num];
[cell.movImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",[imageArray objectAtIndex:indexPath.item]]] placeholderImage:[UIImage imageNamed:@"Main_Logo.png"]];
[cell.movImage setShowActivityIndicatorView:YES];
[cell.movImage setIndicatorStyle:UIActivityIndicatorViewStyleWhite];
return cell;
}
当我在模拟器上运行项目时,它滚动顺畅,但在物理设备上运行时,它滚动不顺畅。我该如何解决这个问题?
【问题讨论】:
-
我建议你使用时间分析仪仪器
-
我认为你不需要在 cellForItemAt 方法中循环,只需使用 num = [[numArray objectAtIndex:indexPath.item]integerValue]; cell.itemNo.text = [NSString stringWithFormat:@"%ld", (long)num];没有任何 for 循环
-
我已经使用了,但没有找到任何解决方案 Paul。
-
尝试删除循环,检查@user1000 评论
-
我使用了您的代码,但它在 iPad 中滚动不流畅。 @Reinier
标签: ios objective-c uicollectionview