“打开方式”如何? iPhone中的一些应用工作? [英] How does "Open With" some app in iPhone work?

查看:114
本文介绍了“打开方式”如何? iPhone中的一些应用工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,从iOS SDK 3.2开始,添加了文件类型处理,iOS应用程序可以将自身与某种文件类型相关联,以便其他应用程序可以使用该应用程序打开此类文件。

As far as I know, from iOS SDK 3.2, file type handling is added and an iOS application can associate itself with some file type so that other applications can open this kind of file with the application.

由于iOS中的沙盒机制,我想知道appA中的文件何时用appB打开,appB注册了这种文件,会发生什么?此文件是否已复制到appB,appA和appB都会保留此文件的副本?如果答案是肯定的,是否可以让appB在appA的文档文件夹下打开文件?我找不到任何Apple文档。

Because of the sandbox mechanism in iOS, I wonder when a file in appA is opened with appB, which registered itself with this kind of file, what will happen? Is this file copied to appB and both appA and appB keep a copy of this file? If the answer is yes, is it possible to make appB open the file under appA's document folder? I cannot find any Apple documentation on this.

例如,appA在其中存储了一个Keynote文档,如果我用Keynote应用程序打开这个Keynote文档,是否可以让Keynote应用程序编辑这个文档,以便编辑后,appA可以看到更新的文档?

For example, appA stores a Keynote document in it, if I open this Keynote document with the Keynote app, is it possible to let Keynote app to edit this document in place so that after editing, appA can see the updated document?

任何帮助都表示赞赏。

推荐答案

这里有几个不同的问题。

There are a few different questions in here.

当您注册应用程序来处理文件类型时使用info.plist条目文档类型您的应用程序将位于使用该文件执行操作时显示的应用程序列表中(例如,在文件中点击文件附件)电子邮件)。然后,当您的应用程序启动时,方法 application:didFinishLaunchingWithOptions:正常运行, launchOptions 字典将包含发送到您的应用程序的文件的路径。你对该文件的处理取决于你,但它是文件的副本,而不是它的链接。因此,如果用户在原始应用中对文件进行了更改,则必须使用新文件再次启动您的应用。

When you register your app to handle types of files using the info.plist entry Document types your app will be on the list of apps that are shown when you perform an action with that file (for example tapping a file attachment in an email). Then when your app is launched, the method application:didFinishLaunchingWithOptions: is run as normal, and the launchOptions dictionary will contain the path to the file that was sent to your app. What you do with the file from there is up to you, but it is a copy of the file, not a link to it. So if the user makes changes to the file in the original app they must 'launch' your app again, with the new file.

有关详细信息,请参阅此处: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:didFinishLaunchingWithOptions

See here for more info: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:didFinishLaunchingWithOptions:

您无法使用当前SDK访问任何其他应用程序的文档文件夹。

You can't access any other app's document folder with the current SDK.

此外,用于共享文档iTunes(如Pages,Numbers等)查看两个info.plist条目文档类型 UIFileSharingEnabled 。 (苹果文档: http://developer.apple.com/library/ios/#documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW20 )基本上,通过将 UIFileSharingEnabled 设置为 YES ,您将公开 / Documents iTunes中的应用目录。然后再次由用户向用户显示该目录中的内容。

Also, for sharing documents in iTunes (like Pages, Numbers etc), look into the two info.plist entries Document types and UIFileSharingEnabled. (Apples docs: http://developer.apple.com/library/ios/#documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW20) Basically, by setting UIFileSharingEnabled to YES you will expose the /Documents directory of your app in iTunes. Then again it's up to your to show the user once they are back in your app what's in that directory.

这篇关于“打开方式”如何? iPhone中的一些应用工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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