Contents

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 to nil means all supported types can be shown.

  • preferredItemEncoding:

    The encoding disambiguation policy of the selected item. Default is .automatic. Setting it to .automatic means 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