Contents

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 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.

Discussion

The user explicitly grants access only to items they choose, so photo library access authorization is not needed.

See Also

Selecting photos