【发布时间】:2019-05-27 09:16:17
【问题描述】:
我想从用户手机上的所有智能相册中获取图片资源。目前我正在获取图像和视频,但这不是我想要的。
在我的研究中,我总是找到相同的解决方案,但它似乎不再起作用,因为这些问题已经存在好几年了。所以我找不到任何最新的解决方案。
这是我找到的解决方案
let fetchOptions = PHFetchOptions()
fetchOptions.predicate = NSPredicate(format: "mediaType = %d", PHAssetMediaType.image.rawValue)
let smartAlbums = PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .any, options: fetchOptions)
let fetchAssetsResult = PHAsset.fetchAssets(in: collection, options: fetchOptions)
在执行这行代码时,我收到以下错误消息
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unsupported predicate in fetch options: mediaType == 1'
有什么新的可行的解决方案吗?
【问题讨论】:
标签: ios swift swift4 ios11 ios12