Swift 4.2 UIDocumentBrowser View Controller Powerpoint PPTX文件变灰

时间:2019-02-25 10:45:10

标签: swift xcode uti uidocumentbrowservc

我在Swift的Xcode 10.1中使用基于文档的应用程序模板。开箱即用,它不支持许多文件类型,因此我添加了许多文档类型,其中包括各种可以正常工作的Microsoft Office格式(doc,xls,ppt)。我还为docx,xl​​sx和pptx添加了开放的xml格式。除了运行应用程序时仍显示为灰色的pptx之外,这些命令也可以正常工作。我也尝试过使用导入的UTI部分,但没有成功。这是Info.plist的摘录,其中显示docx和xlsx条目(有效)和等效的pptx条目无效。

这些作品:

 <dict>
    <key>CFBundleTypeIconFiles</key>
    <array/>
    <key>CFBundleTypeName</key>
    <string>wordx</string>
    <key>CFBundleTypeRole</key>
    <string>Viewer</string>
    <key>LSHandlerRank</key>
    <string>Alternate</string>
    <key>LSItemContentTypes</key>
    <array>
        <string>org.openxmlformats.wordprocessingml.document</string>
    </array>
</dict>
<dict>
    <key>CFBundleTypeIconFiles</key>
    <array/>
    <key>CFBundleTypeName</key>
    <string>excelx</string>
    <key>CFBundleTypeRole</key>
    <string>Viewer</string>
    <key>LSHandlerRank</key>
    <string>Alternate</string>
    <key>LSItemContentTypes</key>
    <array>
        <string>org.openxmlformats.spreadsheetml.sheet</string>
    </array>
</dict>

虽然不是:

    <dict>
        <key>CFBundleTypeIconFiles</key>
        <array/>
        <key>CFBundleTypeName</key>
        <string>powerx</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHanderRank</key>
        <string>Default</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>org.openxmlformats.presentationml.presentation</string>
        </array>
    </dict>

我也尝试了导入的UTI失败:

<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
<string>public.content</string>
</array>
<key>UTTypeDescription</key>
<string>powerpoint pptx</string>
<key>UTTypeIconFiles</key>
<array/>
<key>UTTypeIdentifier</key>
<string>org.openxmlformats.presentationml.presentation</string>
<key>UTTypeTagSpecification</key>
<array>
<string>pptx</string>
<string>application/vnd.openxmlformats-officedocument.presentationml.presentation</string>
</array>
</dict>
</array>

谢谢您的任何帮助。

1 个答案:

答案 0 :(得分:0)

根据文档here,ppt文件的UTI标识符为com.microsoft.powerpoint.​ppt

因此您可以尝试:

<dict>
    <key>CFBundleTypeIconFiles</key>
    <array/>
    <key>CFBundleTypeName</key>
    <string>powerx</string>
    <key>CFBundleTypeRole</key>
    <string>Viewer</string>
    <key>LSHanderRank</key>
    <string>Default</string>
    <key>LSItemContentTypes</key>
    <array>
        <string>com.microsoft.powerpoint.​ppt</string>
    </array>
</dict>