Using the new inline PhotosPicker
style in iOS 17, it isn't made clear how to handle the cancel button's input, and i cannot seem to find an answer in the documentation.
PhotosPicker(
"Select picture",
selection: $selected,
selectionBehavior: .default,
photoLibrary: .shared()
)
.photosPickerStyle(.inline)
Does anybody have a solution or is this a bug that needs to be fixed?
If you don't need the "Cancel" button, you can hide it using .photosPickerDisabledCapabilities(.selectionActions)
.
If you want to dismiss the picker when "Cancel" button is tapped, you can observe changes to $selected
binding and check if it is empty.
Usually, .inline
style is used with .continuous
selection behavior, .photosPickerDisabledCapabilities(.selectionActions)
and .photosPickerAccessoryVisibility(.hidden)
.