是否有人知道这样做的任何样本或开源代码?或者是一篇解释如何操作的文章?
Is anyone aware of any sample or open-source code that does this? Or a write-up explaining how to do it?
Apple有很多示例代码可以在其他应用程序中打开网址。但我找不到任何应用程序要求其他应用程序打开存储在手机上的文件的示例。
Apple has quite a bit of sample code that opens web addresses in other apps. But I can't find any examples where the app asks another app to open a file that is stored on the phone.
谢谢。
推荐答案有两种方法可以做到。
1)如果您可以将文件编码为字符串,您可以通过 NSURL 将其传递给另一个应用程序。接收应用程序ReceivingApp必须实现
1) If you can encode your file as a string, you can pass it to another app via an NSURL. The receiving app, "ReceivingApp" must implement the
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url在它的应用程序委托中。使用
in it's application delegate. Send your data using the
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"receivingapp://your.data.goes.here"]]];2)使用粘贴板。
我会使用自定义URL方案,因为它1)将为您节省几个步骤; 2)如果接收应用程序出现问题,它不会让操作系统的其余部分访问您的数据。我不确定NSURL的字符限制是什么,但它非常大。
I would use the custom URL scheme since it 1) will save you a few steps and 2) it doesn't give the rest of the OS access to your data should something go amiss with the receiving app. I'm not sure what the character limit on an NSURL is, but it's pretty big.
更多推荐
将文件传递给另一个Iphone应用程序
发布评论