iosswiftuiimagepickercontroller

Preselecting images with UIImagePickerController


I have a standard code to open image picker, to select multiple images with it:

private func openFilesAction() {

    if UIImagePickerController.isSourceTypeAvailable(.photoLibrary) {
        let imagePicker = UIImagePickerController()
        customizePicker(picker: imagePicker)
        imagePicker.delegate = self
        imagePicker.mediaTypes = ["public.movie"]
        imagePicker.sourceType = .photoLibrary;
        imagePicker.allowsEditing = false
        imagePicker.videoExportPreset = AVAssetExportPresetPassthrough
        imagePicker.videoQuality = .typeHigh
        self.present(imagePicker, animated: true, completion: nil)
    }
}

But, I would like to have an ability to open picker again, and add or remove pictures to current selection. So the next time I open a picker, previously chosen images to be preselected.

Is this possible with a default picker, or I will have to do it custom (using CollectionView)?


Solution

  • You are not able to use multiple selection and preselection using UIImagePickerController