photosPicker(isPresented:selection:matching:preferredItemEncoding:)
Presents a Photos picker that selects a PhotosPickerItem.
Declaration
nonisolated func photosPicker(isPresented: Binding<Bool>, selection: Binding<PhotosPickerItem?>, matching filter: PHPickerFilter? = nil, preferredItemEncoding: PhotosPickerItem.EncodingDisambiguationPolicy = .automatic) -> some View
Parameters
- isPresented:
The binding to whether the Photos picker should be shown.
- selection:
The item being shown and selected in the Photos picker.
- filter:
Types of items that can be shown. Default is
nil. Setting it tonilmeans all supported types can be shown. - preferredItemEncoding:
The encoding disambiguation policy of the selected item. Default is
.automatic. Setting it to.automaticmeans the best encoding determined by the system will be used.
Discussion
The user explicitly grants access only to items they choose, so photo library access authorization is not needed.
See Also
Selecting photos
PhotosPickerphotosPicker(isPresented:selection:matching:preferredItemEncoding:photoLibrary:)photosPicker(isPresented:selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:)photosPicker(isPresented:selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:photoLibrary:)photosPickerAccessoryVisibility(_:edges:)photosPickerDisabledCapabilities(_:)photosPickerStyle(_:)