Possible ways to speed up reading from ALAssetsLib

2020-06-29 09:01发布

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.

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?

Thank you!

1条回答
ら.Afraid
2楼-- · 2020-06-29 09:28

Just enumerate the assets you currently need to display by using enumerateAssetsAtIndexes:(NSIndexSet *)indexSet options:(NSEnumerationOptions)options usingBlock:(ALAssetsGroupEnumerationResultsBlock)enumerationBlock of your asset group and not by using - (void)enumerateAssetsUsingBlock:(ALAssetsGroupEnumerationResultsBlock)enumerationBlock

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.

查看更多
登录 后发表回答