如何在“打开方式”中获取我的应用程序

时间:2013-02-24 22:33:32

标签: ios objective-c

我正在寻找一种方法在“打开方式”菜单中提出我的应用程序。  我在主题上看到了这个StackOverflow topic,我在plist文件中设置了必要的行,但仍未提出我的应用程序。 我怎么能这样做?

以下是我在plist中设置的代码:

<key>CFBundleDocumentTypes</key>
<array>
        <dict>
            <key>CFBundleTypeExtensions</key>
            <array>
                <string>pdf</string>
            </array>
            <key>CFBundleTypeIconFile</key>
            <string>app.icns</string>
            <key>CFBundleTypeName</key>
            <string>public.pdf</string>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
        <key>LSHandlerRank</key>
            <string>Owner</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>public.pdf</string>
            </array>
    </dict>
        <dict>
            <key>CFBundleTypeExtensions</key>
            <array>
                <string>png</string>
            </array>
            <key>CFBundleTypeIconFile</key>
            <string>app.icns</string>
            <key>CFBundleTypeName</key>
            <string>public.png</string>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>LSHandlerRank</key>
            <string>Owner</string>
            <key>LSItemContentTypes</key>
            <array>
                    <string>public.png</string>
            </array>
        </dict>
</array>

<key>UTImportedTypeDeclarations</key>
<array>
    <dict>
            <key>UTTypeConformsTo</key>
            <array>
                    <string>public.data</string>
            </array>
            <key>UTTypeIdentifier</key>
            <string>public.pdf</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                    <key>com.apple.ostype</key>
                    <string>PDF</string>
                    <key>public.filename-extension</key>
                    <array>
                        <string>pdf</string>
                    </array>
                    <key>public.mime-type</key>
                    <string>application/pdf</string>
            </dict>
    </dict>
        <dict>
            <key>UTTypeConformsTo</key>
            <array>
                    <string>public.image</string>
            </array>
            <key>UTTypeIdentifier</key>
            <string>public.png</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                    <key>com.apple.ostype</key>
                    <string>PNG</string>
                    <key>public.filename-extension</key>
                    <array>
                        <string>png</string>
                    </array>
                    <key>public.mime-type</key>
                    <string>image/png</string>
            </dict>
        </dict>
</array>

1 个答案:

答案 0 :(得分:1)

看起来你所做的只是从你链接的其他答案中复制这些条目。

对于PDF文件和PNG图像,根本不需要第二部分(导入的声明)。这些是众所周知的文档类型。

对于文档类型,我只是这样做:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>PDF</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.adobe.pdf</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleTypeName</key>
        <string>PNG</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.png</string>
        </array>
    </dict>
</array>