【问题标题】:How to share image, text and link using UIDocumentInteractionController in iPhone sdk如何在 iPhone sdk 中使用 UIDocumentInteractionController 共享图像、文本和链接
【发布时间】:2015-01-19 07:33:02
【问题描述】:

如何在 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]; 

图片分享有效,但文字分享无效 谁能帮帮我。

【问题讨论】:

    标签: ios iphone share


    【解决方案1】:

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

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

    _documentInteractionController.name = @"Your Subject";
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-04
      • 2016-01-28
      • 1970-01-01
      相关资源
      最近更新 更多