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

查看:27
本文介绍了如何显示“打开方式..."当用户尝试在 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中设置CFBundleDocumentTypes来注册其打开特定文件类型的能力>plist.这是GoodReader 的用于打开 PDF 的 XML 的示例.

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.

当您的应用程序 调用打开一个文件,可以在application:didFinishLaunchingWithOptions:中找到该文件的信息,通过键传入一个字典href="http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/c/data/UIApplicationLaunchOptionsURLKey" rel="noreferrer">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天全站免登陆