ios - UICollectionView dequeueReusableCellWithReuseIdentifier 导致性能问题

标签 ios objective-c performance uicollectionview

我刚刚开始使用 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/

相关文章:

ios - 通用链接不适用于 iOS10

ios - 在 Swift 中使用 NSMutableAttributedString 更改特定文本的颜色

objective-c - xcode 4.6 中的 UIViewController 子类在哪里

performance - go rpc、http 或 websockets,这是将许多小块数据从一个服务器重复传输到另一个服务器的最快方式

php - ZF2模块加载性能

ios - 如何控制 UIActivityIndi​​catorView 的旋转?

ios - 字符串不可转换为 [AnyObject]

ios - OpenCV matchShapes() 输出值

iphone - Objective-C:我可以用代码“监视”一个变量,以便它更改的瞬间可以将其更改回来?

java - 数组访问如何影响性能?