繁体   English   中英

从照片中获取数据源的UICollectionView-包含大量照片的缓慢更新

[英]UICollectionView with data source fetched from Photos - slow updates with big amount of photos

我正在使用旧的ALAseetLibrary框架开发用于检测照片库中屏幕截图的应用程序 -如果可以,请使用新的照片框架。 我的问题是,当用户的照片库很大时,要花很多时间才能找到屏幕截图。 每次打开应用程序时,我都会更新数据源。

这是扫描照片库的代码:

ALAssetsLibraryGroupsEnumerationResultsBlock savedPhotosBlock = ^(ALAssetsGroup *group, BOOL *stop)
{
    if (group)
    {
        [group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop)
        {
             if(result)
             {
                 ALAssetRepresentation *original = [result defaultRepresentation];
                 CGSize dimensions = [original dimensions];

这项工作完成后,我将调用reloadData() 如何在旅途中更新数据,以便可以在其数据源更新时与UICollectionView进行交互?

您应该使用performBatchUpdate方法。 创建带有要添加的新indexPath的数组。 呼叫insertItemsAtIndexPaths:

而不是reloadData

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM