[英]How to sort photos in Swift based on date added to gallery
My app has a requirement where photos are loaded from iPhone gallery and listed in the app.我的应用程序要求从 iPhone 画廊加载照片并在应用程序中列出。 Currently the sort order is based on
PHAsset creationDate
property.目前排序顺序基于
PHAsset creationDate
属性。 I would like to know how we can sort the assets based on the date added as how we see in All photos on iPhone.我想知道我们如何根据添加的日期对资产进行排序,就像我们在 iPhone 上的所有照片中看到的那样。
I could see that PHAsset
properties creationDate
, modificationDate
and other dates(listed below) from PhAsset
metadata are the same, which is the date taken of the photo.我可以看到
PhAsset
元数据中的PHAsset
属性creationDate
、 modificationDate
和其他日期(如下所列)是相同的,即拍摄照片的日期。
Is there a way to get the date added for a PHAsset
?有没有办法获得为
PHAsset
添加的日期?
You should check out PHFetchOptions you would end up doing something like this你应该检查PHFetchOptions你最终会做这样的事情
let fetchOptions = PHFetchOptions()
let sortOrder = [NSSortDescriptor(key: "creationDate", ascending: false)]
fetchOptions.sortDescriptors = sortOrder
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.