Possible ways to speed up reading from ALAssetsLibrary and populating a UITableView

孤人 提交于 2019-12-05 07:55:23

问题


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:


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.



来源:https://stackoverflow.com/questions/10239242/possible-ways-to-speed-up-reading-from-alassetslibrary-and-populating-a-uitablev

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!