使用自定义URL处理程序在两个iOS应用之间移动数据/图像 [英] Move data/images between two iOS apps using custom URL handler
问题描述
在谷歌搜索并搜索了一段时间后,我找不到答案 -
After googling around and searching SO for a while, I stil couldn't find an answer -
我想知道,我怎么能在两个之间传输数据我的应用使用自定义URL处理程序?特别是图像或NSData对象。
I've wondered, How could I transfer data between two of my apps using custom URL handlers? Specifically images or an NSData object for that matter.
我知道能够使用自定义处理程序打开我的应用程序的特定部分,例如myapp1:// start,myapp2:// start,但我不确定如何通过这些处理程序继续传输大量数据(~80k)。
I know about being able to open specific parts of my app using custom handlers such as myapp1://start , myapp2://start , but I'm not sure how to go on transferring large amounts of data (~80k) through these handlers.
很想听到任何有创意的解决方案:)
Would love to hear any creative solutions :)
ps 解决方案应该是iOS> = 4.3兼容
p.s. The solution should be iOS >= 4.3 Compatible
推荐答案
将自定义URL处理程序与UIPasteboard结合使用。将第一个应用程序(例如图像)中的内容保存到常规粘贴板,如下所示:
Use the custom URL handlers in combination with UIPasteboard. Save something from your first app (say, an image) to the general pasteboard, like so:
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
[[UIPasteboard generalPasteboard] setImage:myImage];
然后使用自定义URL方案切换应用。
Then use the custom URL schemes to switch apps.
然后在需要时从新应用中检索您的图像:
Then retrieve your image from within the new app when you need it:
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
UIImage *tempImg = pasteboard.image;
经过久经考验。 ; )
Battle-tested. ; )
这篇关于使用自定义URL处理程序在两个iOS应用之间移动数据/图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!