Ios7 如何在iOS中将图像文件附加到我的应用程序邮件

Ios7 如何在iOS中将图像文件附加到我的应用程序邮件,ios7,Ios7,我有一个应用程序。点击按钮,我想应用程序的屏幕应该被捕获,MailComposer窗口应该被打开,之前捕获的图像应该被附加到它。已发送邮件,但没有附加的图像文件 请帮帮我。 提前感谢 我的代码在这里 MFMailComposeViewController *controller =[[MFMailComposeViewController alloc] init]; controller.mailComposeDelegate = self; [controller setSubject:@"S

我有一个应用程序。点击按钮,我想应用程序的屏幕应该被捕获,MailComposer窗口应该被打开,之前捕获的图像应该被附加到它。已发送邮件,但没有附加的图像文件

请帮帮我。 提前感谢

我的代码在这里

MFMailComposeViewController *controller =[[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"Screen shot maker"];
[controller setMessageBody:@"Hi , <br/> This is Screen Shot Maker" isHTML:YES];
[controller addAttachmentData:[NSData dataWithContentsOfFile:@"myScreenShot.png"] mimeType:@"png" fileName:@"myScreenShot.png"];

if (controller)
    [self presentModalViewController:controller animated:YES];
使用以下代码:

UIGraphicsBeginImageContext(self.view.bounds.size);
//    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData * data = UIImagePNGRepresentation(image);

MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller addAttachmentData:data mimeType:@"application/image" fileName:@"Test.png"];

if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
{
    controller.modalPresentationStyle = UIModalPresentationFormSheet;
}
else
{
    controller.modalPresentationStyle = UIModalPresentationFullScreen;
}
[self presentModalViewController:controller animated:YES];

非常感谢您,先生,这对我很有用。。。!!!您节省了我的时间,再次感谢您。@user3156787您没有接受我的回答。还有,你能投赞成票吗?@user3156787点击我答案下方的复选标记按钮投赞成票箭头。先生..,我是个新手,所以需要15个声望才能投赞成票,在我获得15个声望之后,我当然会投你一票。谢谢。@user3156787我明白了,但你可以接受我的回答,因为这不需要15个名声。