我刚刚开始使用 Collection View 。这是一个空的 Collection View 单元格,尚未添加任何内容。我只是想先看看它的外观,然后再添加更多 UI 元素。
但是注意到滚动并不顺畅。需要一段时间才能开始滚动。一旦开始滚动,它就会运行良好,直到滚动结束。但当它必须开始滚动时,它又会发生。
在仪器上运行表明双端队列需要时间。
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseCellIdentifier forIndexPath:indexPath];
我的完整 cellForItemAtIndexPath 如下所示:
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *reuseCellIdentifier = @"Reuse";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseCellIdentifier forIndexPath:indexPath];
//cell.backgroundColor = [UIColor whiteColor];
//cell.layer.shouldRasterize = YES;
//cell.layer.rasterizationScale = [UIScreen mainScreen].scale;
return cell;
}
注释行在取消注释时无效。
我可以做些什么来提高性能吗?我的环境是iOS 7模拟器。
最佳答案
别担心,iOS7 模拟器的性能不是很好,在设备上应该不会有任何性能问题。
关于ios - UICollectionView dequeueReusableCellWithReuseIdentifier 导致性能问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19924913/