我如何将图像附加到uiactivityviewcontroller消息ios?

时间:2013-04-02 07:08:16

标签: iphone ios uiactivityviewcontroller

如何将图像附加到UIActivityViewController消息类型。如果以编程方式无法实现,请告诉我如何将图像复制并粘贴到粘贴板。这是我的代码。

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

在上面的代码中,我无法将图像粘贴到邮件正文

1 个答案:

答案 0 :(得分:0)

您无法直接上传图片。您必须将图像转换为数据并上传数据。