加快从ALAssetsLibrary中读取并填充UITableView的可能方法

问题描述:

现在,我正在使用ALAssetsLibrary从ALAssetsGroupSavedPhotos和ALAssetsGroupLibrary中收集照片。将所有资产读入数组后,我填充了UITableView([myTable reloadData])以显示照片。

Right now, I am using the ALAssetsLibrary to gather the photos from ALAssetsGroupSavedPhotos and ALAssetsGroupLibrary. Upon reading all the assets into an array, I populate my UITableView ([myTable reloadData]) to show the photos.

我发现,如果用户有很多照片,是越来越多的延迟。有什么办法可以加快速度吗?尽管Camera Roll或PhotoLibrary中的照片数量很多,默认的UIIMagePicker似乎完全没有延迟。有什么方法可以达到同样的速度?

I find that if the user has many photos, there is an increasing amount of delay. Is there any way to possible speed things up? The default UIIMagePicker seems to have no delay at all, despite the number of photos in the Camera Roll or PhotoLibrary. Is there any way to attain the same speed?

谢谢!

只需使用资产组的 enumerateAssetsAtIndexes:(NSIndexSet *)indexSet选项:(NSEnumerationOptions)选项使用枚举来枚举当前需要显示的资产:(ALAssetsGroupEnumerationResultsBlock)而不是使用-(void)enumerateAssetsUsingBlock:(ALAssetsGroupEnumerationResultsBlock)enumerationBlock

您可以(我想您想填充表格视图),例如,只需枚举 tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)中索引 indexPath.row 处的资产)indexPath 方法。

you could (i suppose you want to fill a table view) for example just enumerate the asset at the index indexPath.row in your tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath method.