我正致力于在 iOS 中制作自定义 Gallery View 为此,我正在使用迄今为止效果很好的照片框架 我无法让它工作的一件事是获取结果以仅返回 VIDEOS
我试过了
let result = PHAssetCollection.fetchAssetCollectionsWithType(.Moment,子类型:.SmartAlbumVideos,选项:nil)
但它仍在检索图像我想知道语法是否错误
感谢帮助
最佳答案
好的,我找到了问题的答案 基本上我需要使用一个谓词,这基本上是说检索媒体类型为视频的 Assets ,并按创建日期对其进行排序
let allVideosOptions = PHFetchOptions()
allVideosOptions.predicate = NSPredicate(format: "mediaType == %d", PHAssetMediaType.Video.rawValue)
allVideosOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
videos = PHAsset.fetchAssetsWithOptions(allVideosOptions)
关于ios - fetchAssetCollectionsWithType 仅检索视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33026480/