我正在尝试使用 Photos 框架重现本机 iOS8 photopicker。我的排序有问题。
可以说我执行以下操作:
- 我在 Camera+ 应用程序中编辑照片并将其保存回图库。
- 我最喜欢另一张照片。
在本机照片选择器中:
- 所有照片(甚至是我收藏的那张)都将按
creationDate
- 我编辑和保存的照片将在底部,因为它是我更改的最后一张。原件将根据其创建日期在其原始位置。
在我的应用程序中,我执行以下操作:
PHFetchOptions *options = [PHFetchOptions new];
options.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:YES]];
options.predicate = [NSPredicate predicateWithFormat:@"mediaType == %ld", PHAssetMediaTypeImage];
PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:self.assetCollection options:options];
我排序creationDate
并得到以下结果:
- 所有照片(甚至是我收藏的那张)都将按
creationDate
- 我编辑的照片将根据它的原始创建日期在它的原始位置之后。
然后我改变我的查询,而不是排序creationDate
,我排序modificationDate
。我得到以下结果:
- 所有照片的顺序几乎与
creationDate
- 我编辑的照片将在底部。这就是我在本机应用程序中想要和喜欢的。
- 最喜欢的照片也将在底部:-(
因此,苹果似乎改变modificationDate
了最喜欢的动作,也可能改变了其他类型的动作,这弄乱了照片的排序。
怎样才能准确地获得 Apple 在其原生应用程序中使用的排序?也许巧妙地使用NSSortDescriptor
?