问题
I need to allow ppt,docx, xlsx and pdf files only to be picked up by document picker in my application. What I need to set as document types when I initialize my document picker?
回答1:
I have added couple of types in the below mentioned code, please check if it solves your issue:
let types: [String] = [kUTTypePDF as String,kUTTypeSpreadsheet as String, kUTTypePresentation as String, "com.apple.iwork.pages.pages", "public.text"]
let documentPicker = UIDocumentPickerViewController(documentTypes: types, in: .import)
documentPicker.delegate = self
documentPicker.modalPresentationStyle = .formSheet
self.present(documentPicker, animated: true, completion: nil)
.
Other available types which you can try:
"com.apple.iwork.pages.pages", "com.apple.iwork.numbers.numbers", "com.apple.iwork.keynote.key","public.image", "com.apple.application", "public.item","public.data", "public.content", "public.audiovisual-content", "public.movie", "public.audiovisual-content", "public.video", "public.audio", "public.text", "public.data", "public.zip-archive", "com.pkware.zip-archive", "public.composite-content", "public.text", " "com.microsoft.word.doc"
Please comment if you have any question.
Happy to help!
来源:https://stackoverflow.com/questions/61118397/need-to-allow-ppt-files-to-be-selected-by-uidocumentpicker