如何显示“打开...”当用户尝试在iOS中打开电子邮件附件时 [英] How to show "Open In..." when a user tries to open email attachments in iOS

查看:182
本文介绍了如何显示“打开...”当用户尝试在iOS中打开电子邮件附件时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到一些iOS应用程序有这个功能:
当用户尝试打开电子邮件附件时,他们可以按住附件几秒钟,弹出菜单会显示两个纽扣。一个按钮显示为在iBooks中打开(例如)。当用户单击它时,应用程序将被运行并打开附件。

I've seen some iOS apps have this function: When a user tries to open an email attachment, they can press and hold on the attachment for a couple of seconds, and a popup menu will appear displaying two buttons. One button reads "Open in iBooks" (for example). When user clicks it, then the app will be run and open the attachment.

我想知道如何注册我的应用程序与特定的文档类型相关联。

I would like to know how to register my application to be associated with a particular document type.

文档打开时会发生什么?是否复制到应用程序可以读取的位置,还是应用程序接收到表示文档的某种对象?

Also what happens to the document when it is opened? Is it copied to a location that can be read by the application, or does the application receive some sort of object representing the document?

如果有人知道如何执行此操作,请告诉我。

If anyone knows how to do this, please let me know. Thx very much.

推荐答案

您的应用程序必须注册其打开特定文件类型的功能 CFBundleDocumentTypes 在其 plist 中。以下是 GoodReader的XML打开PDF的示例

Your app has to register its ability to open specific file types by setting the CFBundleDocumentTypes in its plist. Here's an example of GoodReader's XML for opening PDFs.

当您的应用是调用打开文件,您可以在应用程序中找到有关该文件的信息:didFinishLaunchingWithOptions:,它被传递一个带有 UIApplicationLaunchOptionsURLKey

When you app is called to open a file, you can find the information about the file in application:didFinishLaunchingWithOptions:, which is passed a dictionary with the key UIApplicationLaunchOptionsURLKey

您将获得一个指向要打开的文件的URL。我认为这是只读的,如果你想改变它就必须保存自己的版本。

You'll get a URL pointing to the file to open. I think that it's read-only and you'll have to save your own version if you want to change it.

这篇关于如何显示“打开...”当用户尝试在iOS中打开电子邮件附件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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