移动数据/两之间的iOS应用程序的图像使用自定义URL处理器(Move data/images be

2019-06-27 20:28发布

谷歌搜索周围,一会儿SO搜索后,我还是老样子找不到一个答案 -

我一直在想,我怎么会两个使用自定义URL处理器我的应用程序之间传输数据? 具体的图像或与此有关的一个NSData对象。

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

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

PS溶液应的iOS> = 4.3兼容

Answer 1:

使用自定义URL处理器与UIPasteboard组合。 从保存您的第一个应用程序的东西(比如,图像),以一般的纸板,就像这样:

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

然后,使用自定义URL方案切换应用程序。

然后从新的应用中撷取您的图片,当你需要它:

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

实战检验。 ; )



Answer 2:

一个解决办法是:

  • 实现一个Web服务器
  • 通过与IP-ADRESS自定义URL方案和自定义的Web服务器的包含在URL中的端口打开你的第二个应用程序
  • 路线或参数也添加到您的图片到你的网址

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

另一种解决方案:

  • 启动Bonjour服务
  • 网络中的第二应用程序可以找到这个服务
  • 做一些魔术通过在应用程序之间的数据

编辑:BETTER其他的解决办法:

刚刚发现了另一个,但更有效的方式做到的大型数据集的交流:
这就是所谓的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

这应该这样做。 对于一个网络服务器:有使用谷歌发现吨的实现



Answer 3:

     [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.


Answer 4:

那么,据我可以告诉〜80K是太多的自定义URL处理程序。 但你可以尝试为Base64编码您的数据并将其追加到自定义URL。 但我怀疑,这将有大量数据的工作。

您还可以对一看UIDocumentInteractionController ,其目的是与支持它们的其他应用程序打开的文件。 这是当你打开另一个应用程序附件的邮件应用程序的功能。

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



Answer 5:

使用自定义URL处理器

这是指定的,所以它不会符合您的要求。

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

大自我,并在研究0的努力:

副本图像文件夹

通过URL IPC通信

和我的解决方案没有工作...我不会放弃的鱼,只是教热得到一条鱼。



文章来源: Move data/images between two iOS apps using custom URL handler