photosPicker(isPresented:selection:matching:preferredItemEncoding:photoLibrary:)
Presents a Photos picker that selects a PhotosPickerItem from a given photo library.
Declaration
nonisolated func photosPicker(isPresented: Binding<Bool>, selection: Binding<PhotosPickerItem?>, matching filter: PHPickerFilter? = nil, preferredItemEncoding: PhotosPickerItem.EncodingDisambiguationPolicy = .automatic, photoLibrary: PHPhotoLibrary) -> 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. - photoLibrary:
The photo library to choose from.
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:)photosPicker(isPresented:selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:)photosPicker(isPresented:selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:photoLibrary:)photosPickerAccessoryVisibility(_:edges:)photosPickerDisabledCapabilities(_:)photosPickerStyle(_:)