PHFetch与相册标题的照片

时间:2017-06-26 11:26:16

标签: ios objective-c phasset

在我的应用程序中,我想显示带有相册文件夹的照片库,我有一个专辑的标题,以及如何从资产中获取所有照片,具有特定标题,如收藏夹,最近添加,相机胶卷等。检查我的以下代码以获取专辑标题。

PHFetchOptions *allPhotosfetchOption = [[PHFetchOptions alloc]init];

    allPhotosfetchOption.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]];

    allPhotosfetchOption.predicate = [NSPredicate predicateWithFormat:@"estimatedAssetCount > 0"];

    allPhotosfetchOption.predicate = [NSPredicate predicateWithFormat:@"mediaType == 1"];

    PHFetchResult *result = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];

    [result enumerateObjectsUsingBlock:^(PHAssetCollection *collection, NSUInteger idx, BOOL *stop) {

        NSLog(@"album title %@", collection.localizedTitle);
    }];

输出:

2017-06-26 16:52:05.903 PhFolderNew[4712:147660] album title Panoramas
2017-06-26 16:52:05.904 PhFolderNew[4712:147660] album title Camera Roll
2017-06-26 16:52:05.906 PhFolderNew[4712:147660] album title Slo-mo
2017-06-26 16:52:05.907 PhFolderNew[4712:147660] album title Screenshots
2017-06-26 16:52:05.908 PhFolderNew[4712:147660] album title Bursts
2017-06-26 16:52:05.909 PhFolderNew[4712:147660] album title Videos
2017-06-26 16:52:05.910 PhFolderNew[4712:147660] album title Selfies
2017-06-26 16:52:05.912 PhFolderNew[4712:147660] album title Hidden
2017-06-26 16:52:05.913 PhFolderNew[4712:147660] album title Time-lapse
2017-06-26 16:52:05.916 PhFolderNew[4712:147660] album title Recently Added
2017-06-26 16:52:05.918 PhFolderNew[4712:147660] album title Depth Effect

让我知道如何将收藏夹传递给phasset并从收藏夹中获取所有照片?

0 个答案:

没有答案