iOS"打开..."ZIP文件

Jam*_*son 3 iphone zip xcode objective-c ios

我正在尝试通过内置的"Open With ..."功能导入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>
Run Code Online (Sandbox Code Playgroud)

但是,当启动"打开方式..."视图时,我的应用程序不会显示.为什么是这样?

Tom*_*mmy 7

您的问题是您未能声明相关的统一类型标识符(UTI).对于许多文件类型,您需要导入或导出UTI; 对于zip文件,您无需费心,因为它位于系统固有识别的UTI列表中.

因此,只需将以下内容添加到文档类型即可:

<key>LSItemContentTypes</key>
<array>
    <string>com.pkware.zip-archive</string>
</array>
Run Code Online (Sandbox Code Playgroud)