0

How can attach an image to UIActivityViewController message type. If it is not possible by programatically, then tell me how to copy and paste image to pasteboard. here is my code.

UIImage *image = photoView.image;
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.persistent = YES;
pasteboard.image = photoView.image;

NSString *firstN = [NSString stringWithFormat:@"First Name    : %@",((data.firstName)?data.firstName:@"")];
NSString *lastN = [NSString stringWithFormat:@"Last Name    : %@",((data.lastName)?data.lastName:@"")];
NSString *phoneMob = [NSString stringWithFormat:@"Mobile           : %@",((data.phoneMob)?data.phoneMob:@"")];
NSString *phoneHome = [NSString stringWithFormat:@"Home            : %@",((data.phoneHome)?data.phoneHome:@"")];
NSString *emailOff = [NSString stringWithFormat:@"Email(Off.)     : %@",((data.emailOffice)?data.emailOffice:@"")];
NSString *emailPers = [NSString stringWithFormat:@"Email(Pers.)  : %@",((data.emailPersonal)?data.emailPersonal:@"")];

NSArray *actItems = [NSArray arrayWithObjects:image,pasteboard,firstN,lastN,phoneMob,phoneHome,emailOff,emailPers, nil];

UIActivityViewController *actCtrl = [[UIActivityViewController alloc]initWithActivityItems:actItems applicationActivities:nil];

actCtrl.excludedActivityTypes = @[UIActivityTypePrint,UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact,UIActivityTypeSaveToCameraRoll];

[self presentViewController:actCtrl animated:YES completion:nil ];

In the above code, i couldn't paste the image to the message body

manujmv
  • 6,450
  • 1
  • 22
  • 35

1 Answers1

0

You can't able to directly upload the image. You have to convert image to data and upload the data.

sundar
  • 186
  • 2
  • 5