Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UICollectionView重载ItemSatinDexpath速度会因大量UICollectionViewCell而减慢_Ios_Objective C_Uicollectionview - Fatal编程技术网

Ios UICollectionView重载ItemSatinDexpath速度会因大量UICollectionViewCell而减慢

Ios UICollectionView重载ItemSatinDexpath速度会因大量UICollectionViewCell而减慢,ios,objective-c,uicollectionview,Ios,Objective C,Uicollectionview,我有一个UICollectionView,最多可以加载1000个UICollectionView单元格。根据集合视图中单元格的数量,调用reloadItemsAndExpaths:时,更新UI可能需要很长时间。我已经指出问题(无论如何在我的代码中)存在于重新加载itemsatindexpaths:和collectionView:cellForItemAtIndexPath:使用以下代码: - (void)updateIndexPath:(NSIndexPath *)indexPath {

我有一个
UICollectionView
,最多可以加载1000个
UICollectionView单元格。根据集合视图中单元格的数量,调用
reloadItemsAndExpaths:
时,更新UI可能需要很长时间。我已经指出问题(无论如何在我的代码中)存在于
重新加载itemsatindexpaths:
collectionView:cellForItemAtIndexPath:
使用以下代码:

- (void)updateIndexPath:(NSIndexPath *)indexPath 
{
    NSLog(@"starting reload of row %ld", (long)indexPath.row);
    [self.collectionView reloadItemsAtIndexPaths:@[indexPath]];
    NSLog(@"finished reload of row %ld", (long)indexPath.row);
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
                  cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"begin creating cell at row %ld", (long)indexPath.row);
    // Customise the cell
    NSLog(@"end creating cell at row %ld", (long)indexPath.row);
    return cell;
}
(注意,我一次只想更新1个indexPath)

当集合视图有5个单元格时,只需40毫秒:

2014-03-14 13:07:10.949 Fotobox[2903:60b] starting reload of row 0
2014-03-14 13:07:10.954 Fotobox[2903:60b] begin creating cell at row 0
2014-03-14 13:07:10.974 Fotobox[2903:60b] end creating cell at row 0
2014-03-14 13:07:10.989 Fotobox[2903:60b] finished reload of row 0
但使用316电池需要3.4秒:

2014-03-14 13:08:48.222 Fotobox[2903:60b] starting reload of row 0
2014-03-14 13:08:51.679 Fotobox[2903:60b] begin creating cell at row 0
2014-03-14 13:08:51.708 Fotobox[2903:60b] end creating cell at row 0
2014-03-14 13:08:51.725 Fotobox[2903:60b] finished reload of row 0
我能做些什么来加快速度吗?
我猜这是UICollectionView内部的,但我希望被证明是错误的

谢谢