简体   繁体   中英

How to share image, text and link using UIDocumentInteractionController in iPhone sdk

How to share image with text(link) using UIDocumentInteractionController in iPhone sdk.

My Code:

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]; 

Image share is working but text share is not working Can any one help me.

It doesn't look like you can set message text and send an image with UIDocumentInteractionController: that's for opening/viewing/previewing single documents in other apps.

BTW. The UTI property is for declaring the type of the document (see Uniform Type Identifier Concepts ). But you can set a name for the document which mail will use as the subject:

_documentInteractionController.name = @"Your Subject";

To create a mail use the UIActivityViewController with an NSString message and UIImage image activity items.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM