iOS开发 SwiftUI:PhotosPicker的matching怎么用

大概念
这个参数类型是PHPickerFilter,可选值混合了大概念和小概念,大概念:
- images 所有图片类型,包括LivePhoto(图片+0.5秒的视频)
- videos 所有视频类型
小概念
除了两个大概念之外都是小概念
组合操作
有三个诡异的方法,其实是用来组合的,因为苹果很贴心地屏蔽了内部实现嘛(位运算嘛,一般人容易出错):
- all = AND,参数里面的都做AND啊,基本上就啥也不剩了
- any = OR,这才是组合各种类型的方法
- not = NOT,排除某种类型,可以用于在大概念里排除小概念
另:
返回的选中项是PhotosPickerItem,可用的方法不多,除了loadTransferable(type: Data.self)别的都不可用,无法使用loadTransferable返回URL或UIImage(可以通过Data获得),itemIdentifier也是空的,supportedContentTypes倒是能用,只是内容是一大串文本。
参考:
static let bursts: PHPickerFilter
A filter that represents assets with multiple high-speed photos.
static let cinematicVideos: PHPickerFilter
A filter that represents videos with a shallow depth of field and focus transitions.
static let depthEffectPhotos: PHPickerFilter
A filter that represents photos with depth information.
static let images: PHPickerFilter
The filter for images.
static let livePhotos: PHPickerFilter
The filter for live photos.
static let panoramas: PHPickerFilter
A filter that represents panorama photos.
static let screenRecordings: PHPickerFilter
A filter that represents screen recordings.
static let screenshots: PHPickerFilter
A filter that represents screenshots.
static let slomoVideos: PHPickerFilter
A filter that represents slow-motion videos.
static let timelapseVideos: PHPickerFilter
A filter that represents time-lapse videos.
static let videos: PHPickerFilter
The filter for videos.
static func any(of: [PHPickerFilter]) -> PHPickerFilter
Returns a new filter formed by OR-ing the filters in a given array.
更多推荐

所有评论(0)