如何将iPhone应用程序与_every_文件类型相关联? [英] How to associate iPhone application with _every_ file type?

查看:262
本文介绍了如何将iPhone应用程序与_every_文件类型相关联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有iPhone应用程序另一个邮件客户端应该能够打开任何文件作为附件发送它。因此,我想将此应用程序与任何扩展名的任何文件相关联。

There is iPhone app "Another Mail Client" that should be able to open any file to send it as attachment. So, I want to associate this application with any file with any extension.

在文档之后,我们应声明支持具有根UTI类型的文件 public.data - 任何文件都应属于此类型。它有效,但根本没有。在这种情况下,我们的应用程序将无法打开任何文件,只能打开已在系统中注册的文件。例如,如果在任何应用程序(例如,dropbox)中我们将使用UIDocumentInteractionController尝试使用未知扩展名(file.unknowntype)打开...文件,那么尽管我们已经已经存在,但答案将是否定的注册我们的应用程序,它支持根UTI类型 public.data 。但是,如果您安装另一个支持带扩展名(* .unknowntype)的文件的应用程序,那么我们的应用程序也可以打开这些文件并显示在打开...应用程序列表中。

Following the documentation, we should declare support for files with the root UTI-type public.data – any file should belong to this type. It works, but not at all. In this case, our app will not be able to open any file, but only those which have already been registered in the system. For example, if in any application (e.g., dropbox) we'll try to "open in..." file with an unknown extension (file.unknowntype) using UIDocumentInteractionController, then the answer will be negative despite the fact that we have already registered our application and it supports the root UTI-type public.data. But, if you install another application, which supports files with extension (*.unknowntype), then our application will also be able to open these files and will appear in "open in..." application list.

UPD: @Gabriel这是我的info.plist文件的CFBundleDocumentTypes的一部分:

UPD: @Gabriel This is CFBundleDocumentTypes part of my info.plist file:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>MyMail</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.data</string>
        </array>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHandlerRank</key>
        <string>Default</string>
        <key>CFBundleTypeIconFiles</key>
        <array>
            <string>Icon29.png</string>
            ...
            <string>Icon114.png</string>
        </array>
    </dict>
</array>


推荐答案

我用以下设置创建了一个应用

I've made an app with the following setup

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

当我尝试从Safari打开.pdf时,此应用程序显示在打开... 清单。你可以制作一个示例应用并尝试吗?

When I try to open a .pdf from Safari, this app shows up in "open in.." list. Can you make a sample app and try it?

UPD:

似乎声称'public.data '(也试过public.item,public.content)表示文件,它属于设置系统UTI都知道,而不是任何文件。因此,您将能够处理 99%的文件,用户希望通过电子邮件发送,但不是全部。另一种方法是导出您认为重要的UTI,但默认情况下不在系统UTI中。

It seems like claim 'public.data' (tried also public.item, public.content) means file, which belongs to set "all known to system UTIs", not any file. So, you will be able to handle 99% of files, which users want to send by email , but not all. Another way would be to export UTI that you think are important, but which are not in system UTIs by default.

这篇关于如何将iPhone应用程序与_every_文件类型相关联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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