How to add pagination to PHAsset fetching from Photos Framework?

后端 未结 1 574
小蘑菇
小蘑菇 2020-12-20 04:50

I am trying to get all the photos from cameraRoll using Photos framework but its taking a lot of time to fetch all the photos from cameraRoll.

Is their anyway to add

相关标签:
1条回答
  • 2020-12-20 05:33

    allPhotos is of type PHFetchResult< PHAsset > which is a lazy collection, ie it doesn't actually go out and get the photo until you ask it for one, which is what .enumerateObjects is doing. You can just grab the photos one at a time with the subscript operator or get a range of objects with objects(at:) to page through the collection as needed.

    0 讨论(0)
提交回复
热议问题