本文介绍了需要允许ppt文件由UIDocumentPicker选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只需要在我的应用程序中由文档选择器拾取ppt,docx,xl​​sx和pdf文件.初始化文档选择器时需要设置哪些文档类型?

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?

推荐答案

我在下面提到的代码中添加了几种类型,请检查它是否可以解决您的问题:

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:

如有任何疑问,请发表评论.

Please comment if you have any question.

很乐意提供帮助!

这篇关于需要允许ppt文件由UIDocumentPicker选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 07:05