xcode iOS“打开方式...”ZIP文件

x7yiwoj4  于 2023-02-05  发布在  iOS
关注(0)|答案(2)|浏览(163)

我正在尝试通过内置的“打开方式...”功能导入ZIP文件。
下面是我添加到Info.plist文件中的内容:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>ZIP Archive</string>
        <key>CFBundleTypeIconFile</key>
        <string>zip</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>CFBundleTypeOSTypes</key>
        <array>
            <string>ZIP </string>
        </array>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>zip</string>
        </array>
        <key>CFBundleTypeMIMETypes</key>
        <array>
            <string>application/zip</string>
            <string>application/x-zip</string>
            <string>application/x-zip-compressed</string>
        </array>
    </dict>
</array>

但是,在启动“打开方式...”视图时,我的应用未显示。这是为什么?

guz6ccqo

guz6ccqo1#

您的问题是您没有声明相关的uniform type identifier(UTI),对于许多文件类型,您需要导入或导出UTI;对于zip文件,您不必费心,因为它在系统固有识别的UTI列表中。
因此,只需将以下内容添加到文档类型中就足够了:

<key>LSItemContentTypes</key>
<array>
    <string>com.pkware.zip-archive</string>
</array>
vwhgwdsa

vwhgwdsa2#

扩展@Tommy的答案,您可以在项目中使用Xcode添加此值,如下所示:

相关问题