我的应用程序中有一个画廊,使用UICollectionView
。 单元格大约为70,70大小。 我在画廊中使用来自列表中的ALAssetLibrary
的ALAssets
。
我正在使用通常的模式填充单元格:
-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
mycell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
mycell.imageView.image = [[UIImage imageWithCGImage:[alassetList objectAtIndex:indexpath.row] thumbnail]];
return mycell;
}
我的画廊滚动不流畅。我不知道为什么会这样。我尝试添加NSCache来缓存缩略图像(认为创建图像可能很耗费资源),但这并没有提高性能。
我希望UI像原生应用程序一样顺畅。
现在我怀疑可能是UICollectionViewCell prepareForReuse
中的某些内容阻塞了dequeueReusableCellWithReuseIdentifier
方法,但我使用工具未能找到问题所在。
还有其他可能导致这种情况的因素吗?是否有更快速的方法来准备UICollectionViewCell
或以更快的方式进行dequeue
?