[英]How to sort albums the same as Photos.app
I want to sort albums the same way as Photos.app. 我想以与Photos.app相同的方式对相册进行排序。 I tried every possible PHFetchOptions
for PHAssetCollection.fetchAssetCollections(with type: subtype:options:)
: 我想尽一切可能的PHFetchOptions
为PHAssetCollection.fetchAssetCollections(with type: subtype:options:)
:
sortDescriptors
默认情况下不指定sortDescriptors
localizedTitle
, title
, startDate
, endDate,
estimatedAssetCount` 具有localizedTitle
, title
, startDate
, endDate,
estimatedAssetCount`的sortDescriptors But none gives the same order as Photos.app. 但没有一个给出与Photos.app相同的顺序。
// get Photos timeline
guard let timelineFetchResult = PHCollectionList.fetchMomentLists(with: .momentListCluster, options: nil).firstObject else { return }
// get Moments seperated by photos' creation date
let momentsFetchResult = PHAssetCollection.fetchMoments(inMomentList: timelineFetchResult, options: nil)
// get photos from every Moment
for index in 0 ..< momentsFetchResult.count {
let moment = momentsFetchResult[index]
let assetsFetchResult = PHAsset.fetchAssets(in: moment, options: nil)
// ...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.