只是为了先清除一些快速项目:
我已采取以下措施尝试解决此问题:
我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和UIDocumentPickerViewController
call中使用扩展名进行了测试,但均未成功。
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] 删除。
我来说两句