I would like to hide the files that do not match the document types passed to the UIDocumentPickerViewController, i.e only show those that match.
For example, if the document type is "public.movie", I want only video files and folders to be shown in the picker.
Asked
Active
Viewed 428 times
1

Vinh Hung Nguyen
- 139
- 1
- 11
-
Please share your code. – Rajan Apr 15 '20 at 04:54
-
Does this answer your question? [Need to allow ppt files to be selected by UIDocumentPicker](https://stackoverflow.com/questions/61118397/need-to-allow-ppt-files-to-be-selected-by-uidocumentpicker) – Mohit Kumar Apr 15 '20 at 05:18
-
@MohitKumar Thanks for your help, but that's not what I mean. What I want is that any files which are not video files will not be shown in the picker. – Vinh Hung Nguyen Apr 15 '20 at 05:43
1 Answers
-1
Please try below code:
let types: [String] = ["public.movie", "public.video"]
let documentPicker = UIDocumentPickerViewController(documentTypes: types, in: .import)
documentPicker.delegate = self
documentPicker.modalPresentationStyle = .formSheet
self.present(documentPicker, animated: true, completion: nil)
you can add/remove any value from types as per your need:
let types: [String] = ["public.movie", "public.video"]
Please comment if you have any problem with the code.
Happy to Help!

Mohit Kumar
- 2,898
- 3
- 21
- 34
-
Thanks for your help, but that's not what I mean. What I want is that any files which are not video files will not be shown in the picker. – Vinh Hung Nguyen Apr 15 '20 at 06:00
-
Do you want only video type content or other content types except for video type? I am lil confused here. – Mohit Kumar Apr 15 '20 at 06:02
-
1I want only video type files to appear in the picker. Any other type should disappear, not just gray out. – Vinh Hung Nguyen Apr 15 '20 at 06:12
-
Can you post your code above and a screenshot of the current look? – Mohit Kumar Apr 15 '20 at 06:24