如何使用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/