xcode – 应用内屏幕截图并附加到电子邮件而不保存到库中
发布时间:2020-12-14 18:13:04 所属栏目:百科 来源:网络整理
导读:我想知道我应该使用什么代码如果我想让我的应用程序能够通过按UI按钮截取屏幕截图并立即弹出并邮件撰写并通过电子邮件发送屏幕截图而不将其保存到照片库中? 非常感谢! 解决方法 您需要在项目中添加两个框架 – QuartzCore和MessageUI,然后执行#import Quar
我想知道我应该使用什么代码如果我想让我的应用程序能够通过按UI按钮截取屏幕截图并立即弹出并邮件撰写并通过电子邮件发送屏幕截图而不将其保存到照片库中?
非常感谢! 解决方法
您需要在项目中添加两个框架 – QuartzCore和MessageUI,然后执行#import< QuartzCore / QuartzCore.h>和#import< MessageUI / MessageUI.h>.
你的按钮代码应该是,像, - (void)buttonPress:(id)sender { UIGraphicsBeginImageContext(self.view.frame.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage * image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSData * imageData = UIImageJPEGRepresentation(image,1.0); if ( [MFMailComposeViewController canSendMail] ) { MFMailComposeViewController * mailComposer = [[[MFMailComposeViewController alloc] init] autorelease]; mailComposer.delegate = self; [mailComposer addAttachmentData:imageData mimeType:@"image/jpeg" fileName:@"attachment.jpg"]; /* Configure other settings */ [self presentModalViewController:mailComposer animated:YES]; } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |