使用自定义URL处理器在两个iOS应用程序之间移动数据/图像

search了一会儿后,我仍然无法find答案 –

我想知道,如何使用自定义URL处理程序在两个应用程序之间传输数据? 具体的图像或NSData对象的事情。

我知道能够打开我的应用程序的特定部分使用自定义处理程序,如myapp1://开始,myapp2://开始,但我不知道如何继续通过这些传输大量的数据(〜80K)处理程序。

很想听到任何创造性的解决scheme:)

ps解决scheme应该是iOS> = 4.3兼容

将自定义URL处理程序与UIPasteboard结合使用。 从你的第一个应用程序(比如图像)保存一些东西到一般的纸板上,如下所示:

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; [[UIPasteboard generalPasteboard] setImage:myImage]; 

然后使用自定义urlscheme来切换应用程序。

然后在您需要的时候从新应用程序中检索您的图像:

  UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; UIImage *tempImg = pasteboard.image; 

实战检验。 ; )

一个解决scheme可能是:

  • 实现一个Web服务器
  • 通过自定义urlscheme打开你的第二个应用程序,使用url中包含的IP地址和自定义networking服务器的端口
  • 将路线或参数也添加到您的图片也到您的url

下载并享受你的照片:-)

另一个scheme

  • 开始Bonjour服务
  • 在networking中,第二个应用程序可以find这个服务
  • 做一些魔术来传递应用程序之间的数据

编辑:更好的其他解决scheme:

刚刚发现了另一种更有效的方式来交换更大的数据集:
它被称为UIPasteboard

最好的参考:
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIPasteboard_Class/Reference.html

另一个资源:
http://kmithi.blogspot.in/2012/03/sharing-data-among-ios-applications.html

这应该做到这一点。 对于一个networking服务器:有很多使用谷歌的实现

  [http://www.codeproject.com/Articles/43447/How-to-Use-UIPasteBoard-to-Implement-Custom-Copy-a][1] As you know many of the controls in UIKit now come pre-loaded with the ability to copy and paste text. You can also use this new ability in your own apps to copy and paste other things including: images, SQLite databases, text or any file. This is a great way to share data between your apps if you want to provide users with a suite of apps with integrated functionality. CopyFrom Source Code -(IBAction)copyImageToPasteBoard{ UIPasteboard *appPasteBoard = [UIPasteboard pasteboardWithName:@"CopyFrom" create:YES]; appPasteBoard.persistent = YES; NSData *data = UIImagePNGRepresentation([UIImage imageNamed:@"Old-Time-Photo.jpg"]); [appPasteBoard setData:data forPasteboardType:@"com.appshop.copyfrom.imagedata"]; } -(IBAction)copyStringToPasteBoard{ UIPasteboard *appPasteBoard = [UIPasteboard pasteboardWithName:@"CopyFrom" create:YES]; appPasteBoard.persistent = YES; [appPasteBoard setString:textView.text]; } PasteTo Source Code -(IBAction)pasteImageToPasteBoard{ UIPasteboard *appPasteBoard = [UIPasteboard pasteboardWithName:@"CopyFrom" create:YES]; NSData *data = [appPasteBoard dataForPasteboardType:@"com.appshop.copyfrom.imagedata"]; imageView.image = [UIImage imageWithData:data]; } -(IBAction)pasteStringToPasteBoard{ UIPasteboard *appPasteBoard = [UIPasteboard pasteboardWithName:@"CopyFrom" create:YES]; textView.text = [appPasteBoard string]; } Using UIPasteBoard in iPhone programming is amazingly simple and opens up some possibilities that we did not have a year ago. To use UIPasteBoard you simply create a instance using pasteboardWithName, put stuff into the paste board and then set the persistant property equal to YES. Then any app can get a reference to your paste board and use the data contained within. You can use it for simple strings and even data that you can put into NSData like SQLite databases. 

那么,据我所知,80k是一个自定义的URL处理程序太多了。 但是,您可以尝试对数据进行Base64编码并将其附加到自定义URL。 但是我怀疑它会处理大量的数据。

你也可以看看UIDocumentInteractionController ,它打算用其他支持它们的应用程序打开文件。 这是您使用其他应用程序打开附件时邮件应用程序所执行的操作。

https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIDocumentInteractionController_class/Reference/Reference.html#//apple_ref/doc/uid/TP40009304

使用自定义URL处理程序

这是指定的,所以它不会符合你的规格。

但是,如果你不关心,我会写内存(文件系统)的80K图像,即使80Mb,并通过其他应用程序的“url”。

大自我,努力研究:

复制到图像文件夹

通过url的IPC通信

而我的解决scheme是行不通的…我不给鱼,只是教热得到一条鱼。