【问题标题】:How to sort albums the same as Photos.app如何像 Photos.app 一样对相册进行排序
【发布时间】:2016-10-26 20:39:17
【问题描述】:

我想以与 Photos.app 相同的方式对相册进行排序。我为PHAssetCollection.fetchAssetCollections(with type: subtype:options:)尝试了所有可能的PHFetchOptions

  • 默认不指定sortDescriptors
  • sortDescriptors 与 localizedTitletitlestartDateendDate,estimatedAssetCount`

但没有一个提供与 Photos.app 相同的顺序。

【问题讨论】:

  • @Bill No. 一个是排序相册,一个是排序照片。
  • 你是对的。我撤回了我的近距离投票。你找到答案了吗?

标签: ios photokit


【解决方案1】:
// 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)
    // ...
}

【讨论】:

    猜你喜欢
    • 2013-11-08
    • 2021-05-21
    • 1970-01-01
    • 1970-01-01
    • 2012-10-20
    • 1970-01-01
    • 1970-01-01
    • 2018-10-13
    • 2023-03-28
    相关资源
    最近更新 更多