I have implemented a UIDocumentPickerViewController
using the below code and I want to allow the user to select only a single document. However when the document picker is presented and I rapidly tap on a document twice, the delegate is called twice and two documents are getting added.
func openDocumentPicker() {
let documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: [.jpeg, .png])
documentPicker.delegate = self
documentPicker.allowsMultipleSelection = false
present(documentPicker, animated: true)
}
The delegate I used for single file selection is:
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
// Handle file selection and display the added file on UI
dismiss(animated: true)
}
This is very strange considering there is a dedicated functionality allowsMultipleSelection
which is disabled but does not work. Is there anything I am missing, if not how do I fix this?