如何将图像附加到 uiactivityviewcontroller 消息 ios?
Posted
技术标签:
【中文标题】如何将图像附加到 uiactivityviewcontroller 消息 ios?【英文标题】:how can i attach image to uiactivityviewcontroller message ios? 【发布时间】:2013-04-02 07:08:15 【问题描述】:如何将图像附加到 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】:您无法直接上传图片。您必须将图像转换为数据并上传数据。
【讨论】:
以上是关于如何将图像附加到 uiactivityviewcontroller 消息 ios?的主要内容,如果未能解决你的问题,请参考以下文章
如何将图像从 Android 中的 Drawable 附加到彩信?
如何将两个图像附加到 ios 中的 mfmailcomposer 视图控制器