先来整理一下:
-
我不想打开和/或预览文档,因为我看到了一个常见的答案,它将用户引向执行此操作的依赖项
-
我不想选择任何其他文件类型。我的应用程序特别希望获取一个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 site
获取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
打电话也没有成功。