尝试按字母顺序获取智能相册列表。我尝试对localizedTitle
和title
进行排序,但它们会产生相同的结果。
PHFetchOptions *options = [[PHFetchOptions alloc] init];
options.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"localizedTitle" ascending:YES]];
PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:options];
for (PHAssetCollection *collection in smartAlbums) {
NSLog(@"PHAssetCollection: %@", collection.localizedTitle);
}
日志显示结果未按排序顺序返回:
2015-09-27 13:34:57.054 MyApp[2169:1043459] PHAssetCollection: Panoramas
2015-09-27 13:34:57.055 MyApp[2169:1043459] PHAssetCollection: All Photos
2015-09-27 13:34:57.055 MyApp[2169:1043459] PHAssetCollection: Hidden
2015-09-27 13:34:57.055 MyApp[2169:1043459] PHAssetCollection: Recently Deleted
2015-09-27 13:34:57.055 MyApp[2169:1043459] PHAssetCollection: Videos
2015-09-27 13:34:57.056 MyApp[2169:1043459] PHAssetCollection: Favorites
2015-09-27 13:34:57.056 MyApp[2169:1043459] PHAssetCollection: Slo-mo
2015-09-27 13:34:57.056 MyApp[2169:1043459] PHAssetCollection: Bursts
2015-09-27 13:34:57.056 MyApp[2169:1043459] PHAssetCollection: Time-lapse
2015-09-27 13:34:57.056 MyApp[2169:1043459] PHAssetCollection: Recently Added
我做错了什么?