Nik*_*ani 1 objective-c ios photokit
我愿意白天订购我的结果,以便最老的照片显示在最上面.
我目前正在使用PHAsset fetchAssetsWithMediaType获取照片 :
@property PHFetchResult *photos;
self.photos = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:nil];
Run Code Online (Sandbox Code Playgroud)
理想情况下,我希望按日排序,最早的照片排序.像这样:
[11 Dec]
Photo #20 with creation time 17:00
Photo #21 with creation time 18:30
Photo #22 with creation time 19:00
Photo #23 with creation time 20:40
Photo #24 with creation time 21:00
[10 Dec]
Photo #16 with creation time 10:30
Photo #17 with creation time 11:00
Photo #18 with creation time 12:20
Photo #19 with creation time 13:00
[9 Dec]
Photo #14 with creation time 16:30
Photo #15 with creation time 17:00
Run Code Online (Sandbox Code Playgroud)
我已经看到我可以使用谓词和一些排序描述符(https://developer.apple.com/reference/photos/phfetchoptions)传递PHFetchOptions对象,你能建议我如何指定它们(我相信我应该使用它们来排序它们creationDate属性)这样我就能获得所需的订单?
你应该用 PHFetchOptions
PHFetchOptions *fetchOptions = [[PHFetchOptions alloc] init];
fetchOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:true]];
PHFetchResult *result = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:fetchOptions];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1917 次 |
| 最近记录: |