使用CFBundleDocumentTypes:为什么我的应用程序没有出现在“分享”中?菜单? [英] Using CFBundleDocumentTypes: why does my app not show up in the "Share" menu?

查看:2476
本文介绍了使用CFBundleDocumentTypes:为什么我的应用程序没有出现在“分享”中?菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为所有可能的文件类型注册我的应用。我将以下内容添加到我的info.plist中:

I'm trying to register my app for all possible file types. I added the following to my info.plist:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>public.data</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.data</string>
            <string>public.content</string>
        </array>
    </dict>
</array>

如果我现在在Safari中打开PDF并点击Safari的分享按钮,我的应用程序不会提供。但是,如果我点击PDF本身,顶部会出现一个打开方式按钮,我的应用程序就会列在其中。

If I now open a PDF in Safari and tap Safari's "Share" button, my app is not offered. However if I tap the PDF itself, a button "Open In" appears on top and there my app is listed.

这不是一个真正的问题但会阻止用户将照片导入我的应用程序,因为照片应用程序中没有打开菜单。

This is not a real problem but it prevents users to import photos into my app, because there is no "Open In" menu in the Photos app.

我可以以某种方式注册分享菜单吗?

Can I register for the "Share" menu too somehow?

推荐答案

不幸的是,这是不可能的,因为:

Unfortunately this is not possible, because:

Safari中的共享屏幕使用 UIActivityViewController 来显示一个数字可以使用页面执行的活动。这些活动在 UIActivity.h 中定义,通常是系统定义的活动,例如发布到Facebook 发布到Twitter 消息打印

The share screen in Safari is using UIActivityViewController to display a number of activities that can be performed with the page. Those activities are defined in UIActivity.h and are usually the system-defined activities such as Post to Facebook, Post to Twitter, Message, Print, etc.

要在该屏幕中显示非系统定义的活动,必须创建一个自定义 UIActivity 子类,然后用这些数组初始化 UIActivityViewController

For an non-system defined activity to appear in that screen, one has to create a custom UIActivity subclass and then initialize the UIActivityViewController with an array of these.

另一方面,Open In ...屏幕看起来很相似,但是使用 UIDocumentInteractionController 显示可以打开的应用程序给定的URL / UTI (请勿使用Google UTI ......)

The "Open In..." screen on the other hand looks similar but is using a UIDocumentInteractionController which displays apps that can open the given URL/UTI (don't Google UTI...)

这篇关于使用CFBundleDocumentTypes:为什么我的应用程序没有出现在“分享”中?菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆