无法使用UIDocumentPickerViewController选择PowerPoint(PPTX)文档

CodeBender

只是为了先清除一些快速项目:

  1. 我不想打开和/或预览文档,因为我看到一个常见的答案,将用户引向执行此操作的依赖项
  2. 我不想选择任何其他文件类型。我的应用程序特别想获取一张PowerPoint文档,然后将其传递给API调用

如此说来,我一直无法让选择器允许我打开PPTX,如下所示: 在此处输入图片说明

我已采取以下措施尝试解决此问题:

mdls -name kMDItemContentTypeTree test.pptx针对该文件运行以获取其内容类型。

kMDItemContentTypeTree = (
    "org.openxmlformats.presentationml.presentation",
    "public.data",
    "public.composite-content",
    "public.archive",
    "public.item",
    "org.openxmlformats.presentationml.presentation",
    "org.openxmlformats.openxml",
    "public.zip-archive",
    "public.presentation",
    "public.content",
    "com.pkware.zip-archive" )

然后将其添加到我的info.plist文件中,如下所示:

<dict>
    <key>LSItemContentTypes</key>
    <array>
        <string>org.openxmlformats.presentationml.presentation</string>
        <string>public.data</string>
        <string>public.composite-content</string>
        <string>public.archive</string>
        <string>public.item</string>
        <string>org.openxmlformats.presentationml.presentation</string>
        <string>org.openxmlformats.openxml</string>
        <string>public.zip-archive</string>
        <string>public.presentation</string>
        <string>public.content</string>
        <string>com.pkware.zip-archive</string>
    </array>
    <key>CFBundleTypeName</key>
    <string>PPTX</string>
    <key>LSHandlerRank</key>
    <string>Alternate</string>
</dict>

然后,我引用了这个Apple网站来获取Powerpoint的UTI。

com.microsoft.powerpoint.ppt

最后,我像这样设置电话:

let powerpointType = "com.microsoft.powerpoint.​ppt"
let documentPicker = UIDocumentPickerViewController(documentTypes: [powerpointType], 
                                                    in: .import)

但是,如初始图像所示,这不允许我选择文件。因此,我希望找到缺少的部分,以便仅选择PowerPoint文件。

**更新**根据Matt的评论,我确实将值添加到了plist中,但仍然无法选择文件。

在此处输入图片说明

我另外pptx在plist和UIDocumentPickerViewControllercall中使用扩展名进行了测试,但均未成功。

托马斯·迪尼奥

org.openxmlformats.presentationml.presentation是由iOS定义的,因此您无需将其包含在导入的类型中。该定义已由iOS导入。

  • 如果在共享pptx文件时需要使应用程序在共享表中可用,则只需添加CFBundleDocumentTypes条目。但是,由于您说只能处理这些文件,而不能打开它们,因此这可能不合适。也许您想要写的是共享扩展。

  • 如果您只想在中选择pptx文件UIDocumentPickerViewController,则无需在plist文件中添加任何内容!只需使用documentTypes:["org.openxmlformats.presentationml.presentation"]

最后,一些评论:

  • com.microsoft.powerpoint.​ppt是二进制PowerPoint文件(.ppt)的UTI。对于pptx,您需要使用openxmlformats。

  • 您无需要求支持,定义其他选择器或将其添加到选择器的允许UTI列表中。内容类型树的Spotlight属性中列出的其他类型是pptx的父类型。例如,如果将public.presentation添加到列表中,则还可以打开Keynote文件。这可能不是您想要的。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用python-pptx检查图像在PowerPoint中是否具有装饰性

当我使用UIDocumentPickerViewController从iCloud中选择zip文件时,无法与助手应用程序进行通信

无法使用UIDocumentPickerViewController选择多个文件

使用Cordova在Android上打开PowerPoint和Word文档

JavaScript与PowerPoint文档的交互

如何在选择文档并使用UIDocumentPickerViewController下载到设备之前在iCloud中查找文档的大小

使用UIDocumentPickerViewController选取文件时,如何启用多个文件选择?

使用Python编辑基础PowerPoint XML(python-pptx)

如何使用python-pptx从PowerPoint中的“组形状”中的文本形状中提取文本。

如何使用python-pptx选择保存目录?

一位用户无法选择文档

如何使用UIDocumentPickerViewController选择自定义类型?

如何使用python pptx从powerpoint ppt下载或保存图片

使用python-pptx打印Powerpoint幻灯片

使用Python-pptx,PowerPoint可以在什么条件下出现KeyError?

无法使用UIDocumentPickerViewController选择页面文件

如何使用Python-pptx在PowerPoint中的群集条形图上反转类别顺序?

使用python-pptx在PowerPoint中删除超链接

将PowerPoint pptm保存到pptx

在Linux中从Powerpoint PPTX提取文本的工具?

Xamarin表单中的UIDocumentPickerViewController选择

以编程方式更改/添加pptx powerpoint的缩略图。使用Openxml SDK?

OrientDB:无法从连接的文档中选择数据

python pptx PowerPoint 幻灯片构建——无法理解模式/构建方法

有没有办法在使用 UIDocumentPickerViewController 时保留原始选择文件的大小写?

无法为 Powerpoint 折线图的 X 轴选择值

如何使用python pptx复制PowerPoint幻灯片?

在使用 python-pptx 操作 PowerPoint XML 时查找子元素是否存在

使用 Python 將 Powerpoint PPT 文件轉換為 PPTX