ios - 如何在iPhone SDK中使用UIDocumentInteractionController共享图像,文本和链接

标签 ios iphone share

如何使用iPhone SDK中的UIDocumentInteractionController与文本(链接)共享图像。

我的代码:

NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];

// If you go to the folder below, you will find those pictures
NSLog(@"%@",docDir);

NSLog(@"saving png");
NSString *pngFilePath = [NSString stringWithFormat:@"%@/test.png",docDir];
NSData *data1 = [NSData dataWithData:UIImagePNGRepresentation([self screenShotWithScroll])];
[data1 writeToFile:pngFilePath atomically:YES];

_documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:pngFilePath]];
_documentInteractionController.delegate = self;
_documentInteractionController.UTI = @"Your Msg";
[_documentInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:self.view animated: YES]; 

图片共享有效,但文本共享无效
谁能帮我。

最佳答案

您似乎无法设置消息文本并使用UIDocumentInteractionController发送图像:用于在其他应用程序中打开/查看/预览单个文档。

顺便说一句。 UTI属性用于声明文档的类型(请参阅Uniform Type Identifier Concepts)。
但是,您可以为将邮件用作主题的文档设置名称:

_documentInteractionController.name = @"Your Subject";

要创建邮件,请使用带有NSString消息和UIImage图像 Activity 项的UIActivityViewController。

关于ios - 如何在iPhone SDK中使用UIDocumentInteractionController共享图像,文本和链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27056544/

相关文章:

iphone - 以编程方式将 UINavigationBarController 作为第一个选项卡添加到现有导航 Controller 中

c++ - 类之间传递值

ios - 为什么 UITableview 单元格内容在滚动时缩放?

ios - println(NSString(data : data, encoding : NSUTF8StringEncoding)) means in swift?)中的这些(响应、数据、错误)是什么

iphone - 在完成处理程序中执行选择器不起作用?

iOS 6 Facebook 发布程序以 "remote_app_id does not match stored id"结束

iphone - 当用户在不同的选项卡中时,如何在一个选项卡上 popToRoot?

ios - 架构 arm64 的 112 个重复符号

eclipse - 通过软件更新安装时为 Eclipse 3.4+ 插件指定目标文件夹

android - Facebook 分享对话框始终仅在 Android 上显示验证码