- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
Swift 和 iOS 开发的新手。有人能告诉我如何将两次调用 PHAssetCollection.fetchAssetCollectionsWithType 的结果结合起来吗?具体来说,我试图获得一个列表,其中包含一个列表中的标准相册和智能相册。
谢谢
最佳答案
我不确定这是否是最佳实践或其他什么,但我今天需要做这样的事情并且以下似乎有效:
@property NSMutableArray<PHAssetCollection *> *collections;
...
/* Get albums of interest */
PHFetchResult *albums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype: ... options: ...];
/* Get smart albums of interest (in my case, the Camera Roll) */
PHFetchResult *cameraRoll = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeSmartAlbumUserLibrary options: ...];
/* Load albums into collections member */
for (NSUInteger i = 0; i < albums.count; ++i)
[self.collections addObject:[albums objectAtIndex:i]];
/* Load Camera Roll into collections member */
[self.collections addObject:[cameraRoll firstObject]];
请记住在向其添加对象之前初始化您的集合成员。
关于ios - 将 2 个 PHFetchResults 组合在一起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35736558/
我只是想将位于名为“MyFolder”的自定义文件夹中的照片访问到我的 UICollectionView。我可以使用以下代码轻松地处理“所有照片和视频”,但我不知道如何过滤结果以仅包含我的文件夹名称:
我正在尝试从照片库中获取两个日期和 I am getting the images successfully. 范围内的图像使用 PHAsset 库 现在的问题是我无法在同一天的两次之间(例如中午 1
我正在尝试构建一个简单的照片选择器,目前有两个选项:最近和收藏夹。我正在做的是尝试在 creationDate 之前获取所有照片,但这是在我的数据源中以错误的顺序返回图像。数据源的开头是几年前的照片,
我正在开发一个 iOS 应用程序,它可以从照片库中获取视频,并且它始终有效。我刚刚在不同的设备上测试了该应用程序(这不是我测试的第一个),当我使用检索到的数据时它崩溃了,我不明白为什么...... 这
NSString *predicateFormat = [NSString stringWithFormat: @"mediaSubtype = %zd", PHAssetMediaSubtypeVi
我正在使用 YangMingShan作为照片选择器,这正是我所需要的,但是当用户有很多照片时我遇到了问题。 我一直在使用包含 25,000 多张照片和 250 个相册的手机进行测试,当我展示 View
在 swift 3 中,该方法向我显示“'enumerateObjects' 的使用不明确”,发生了什么。我该怎么办? extension PHFetchResult { public func as
我遇到了以下编译错误: Cannot invoke 'enumerateObjectsUsingBlock' with an argument list of type '((_, _, _) ->
我正在尝试向 PHFetchResult 添加扩展以将结果对象作为正确类型的数组拉出 - 到目前为止,我无法弄清楚如何避免下面看到的复制。除了类型约束之外,以下扩展是相同的。如果我使用 PHObjec
Swift 和 iOS 开发的新手。有人能告诉我如何将两次调用 PHAssetCollection.fetchAssetCollectionsWithType 的结果结合起来吗?具体来说,我试图获得一
我正在尝试使用 iOS 8 中的新照片框架获取在设备上拍摄的最后一张照片的缩略图。我现在拥有的执行此操作的代码如下: PHFetchOptions *fetchOptions = [PHFetchOp
我可以使用以下代码从照片库中获取照片列表。 guard let assetCollection = collection as? PHAssetCollection
不太确定为什么我得到“在 Swift 3 中‘枚举对象’的使用不明确。 let collections = PHAssetCollection.fetchAssetCollections(with:
这是我的代码: var galleryController: GalleryController! var albums: PHFetchResult = PHFetchResult(
我是一名优秀的程序员,十分优秀!