iOS PHCollectionList详解
来源:互联网 发布:大麦网抢票软件个人版 编辑:程序博客网 时间:2024/04/27 06:30
iOS
PHCollectionListType
PHCollectionListSubtype
详解
typedef NS_ENUM(NSInteger, PHCollectionListType) { PHCollectionListTypeMomentList = 1,//按照图片的时刻既时间进行分类 PHCollectionListTypeFolder = 2,//按照目录分类 PHCollectionListTypeSmartFolder = 3,//按照智能目录分类} PHOTOS_ENUM_AVAILABLE_IOS_TVOS(8_0, 10_0);typedef NS_ENUM(NSInteger, PHCollectionListSubtype) { // PHCollectionListTypeMomentList subtypes PHCollectionListSubtypeMomentListCluster = 1,//按照族群分类 PHCollectionListSubtypeMomentListYear = 2,//按照年份分类 // PHCollectionListTypeFolder subtypes PHCollectionListSubtypeRegularFolder = 100, // PHCollectionListTypeSmartFolder subtypes PHCollectionListSubtypeSmartFolderEvents = 200, PHCollectionListSubtypeSmartFolderFaces = 201, // Used for fetching if you don't care about the exact subtype PHCollectionListSubtypeAny = NSIntegerMax} PHOTOS_ENUM_AVAILABLE_IOS_TVOS(8_0, 10_0);在实际测试中发现PHCollectionListType 为PHCollectionListTypeFolder或PHCollectionListTypeSmartFolder使用如下方法测试 发现都是空 这两个分类暂时不做分析 估计用处不大那就分析PHCollectionListTypeMomentList这个在PHCollectionListType为PHCollectionListTypeMomentList 分别测试PHCollectionListSubtype发现PHCollectionListSubtypeMomentListCluster和PHCollectionListSubtypeMomentListYear有数据 并且数据相同其他的都没有数据可以发现对于list使用 PHCollectionListTypeMomentList 和 (PHCollectionListSubtypeMomentListCluster和PHCollectionListSubtypeMomentListYear)都行就选第一个PHCollectionListSubtypeMomentListCluster吧。/** 按照每天的数据对照片进行排序 */- (void)getSystemContentImages{// PHFetchResult *fetchResult = [PHCollectionList fetchMomentListsWithSubtype:PHCollectionListSubtypeAny options:nil ];// // PHFetchResult *collectionlists = [PHCollectionList fetchCollectionListsWithType:PHCollectionListTypeSmartFolder subtype:PHCollectionListSubtypeAny options:nil];// PHFetchResult *collectionlists1 = [PHCollectionList fetchCollectionListsWithType:PHCollectionListTypeMomentList subtype:PHCollectionListSubtypeMomentListYear options:nil]; PHFetchResult *collectionlists1 = [PHCollectionList fetchCollectionListsWithType:PHCollectionListTypeMomentList subtype:PHCollectionListSubtypeAny options:nil]; //NSArray *allLists = @[fetchResult, collectionlists, collectionlists1]; //NSArray *allLists = @[fetchResult]; NSArray *allLists = @[collectionlists1];// NSArray *allLists = @[fetchResult]; for (PHFetchResult *fetchResultList in allLists) { [fetchResultList enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if ([obj isKindOfClass:[PHCollectionList class]]) { PHCollectionList *collectionList = (PHCollectionList *)obj; [self phassetWithPHCollectionList:collectionList]; } }]; }// [fetchResults enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {// if ([obj isKindOfClass:[PHCollectionList class]]) {// PHCollectionList *collectionList = (PHCollectionList *)obj;// [self phassetWithPHCollectionList:collectionList];// }// }];}- (void)phassetWithPHCollectionList:(PHCollectionList *)collectionList{ PHFetchResult<PHCollection *> *collections = [PHCollectionList fetchCollectionsInCollectionList:collectionList options:nil]; NSMutableArray<AssetsGroupModel *> *arrM = [NSMutableArray arrayWithCapacity:0]; for (id obj in collections) { if ([obj isKindOfClass:[PHAssetCollection class]]) { PHAssetCollection *assetCollection = (PHAssetCollection *)obj; AssetsGroupModel *groupModel = [AssetsGroupModel new]; groupModel.groupName = assetCollection.localizedTitle; NSLog(@"相簿名:%@", assetCollection.localizedTitle); PHFetchResult<PHAsset *> *assetsFetchResults = [PHAsset fetchAssetsInAssetCollection:assetCollection options:nil]; [assetsFetchResults enumerateObjectsUsingBlock:^(PHAsset * _Nonnull asset, NSUInteger idx, BOOL * _Nonnull stop) { // Photos library UIScreen *screen = [UIScreen mainScreen]; CGFloat scale = screen.scale; // Sizing is very rough... more thought required in a real implementation //CGSize size = CGSizeMake(_asset.pixelWidth, _asset.pixelHeight); CGFloat imageSize = MAX(screen.bounds.size.width, screen.bounds.size.height) * 1.5; CGSize imageTargetSize = CGSizeMake(imageSize * scale, imageSize * scale); AssetModel *model = [AssetModel assetWithPHAsset:asset targetSize:imageTargetSize]; [groupModel.assetsArrM addObject:model]; }]; [arrM addObject:groupModel]; } } //NSLog(@"arrM is %@", arrM);}
阅读全文
0 0
- iOS PHCollectionList详解
- PHCollectionList+Extension
- 【iOS】iOS之viewcontroller详解
- iOS CALayer详解,动画详解。
- IOS CBAC详解
- 苹果ios详解
- ios NSFileManager 用法详解
- 详解iOS App生命周期
- ios property详解
- 详解iOS App生命周期
- ios UIView详解~~~~~
- IOS沙盒详解
- IOS内存管理详解
- iOS学习--UIView详解~~~~~
- ios 动画详解
- iOS ASIHTTPRequest详解
- IOS控件UITableView详解
- 详解iOS生命周期
- poj1017
- java.net.SocketException: Permission denied: connect
- 我为什么要写编程教程?
- log4j的几种常用配置
- 选择你的Docker管理工具:Kubernetes或Swarm
- iOS PHCollectionList详解
- Glassfish不同WEB项目调用ejb对象
- jQuery Ajax 实例 ($.ajax、$.post、$.get)
- 盗梦空间
- Android系统--输入系统(十四)Dispatcher线程情景分析_dispatch前处理
- Cause: java.sql.SQLException: ORA-01841: (完整) 年份值必须介于 -4713 和 +9999 之间, 且不为 0
- 已解决:HorizontalScrollView的setScrollViewListener方法不兼容低版本的问题
- 1022. D进制的A+B (20)
- 块级元素和行内元素的区别