[英]How to attach images in Mail Composer?
我想使用Mail Composer,它也應該附加一個圖像文件,這怎么可能?
你可以測試這段代碼,它完美地工作......
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
[mailController setSubject:@"Hello iPhone"];
[mailController setMessageBody:@"This is the MailSend Application...." isHTML:NO];
UIImage *pic = [UIImage imageNamed:@"Image box with border-1.png"];
NSData *exportData = UIImageJPEGRepresentation(pic ,1.0);
[mailController addAttachmentData:exportData mimeType:@"image/jpeg" fileName:@"Picture.jpeg"];
[self presentModalViewController:mailController animated:YES];
[mailController release];
}
- (void)mailComposeController:(MFMailComposeViewController*)mailController
didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self becomeFirstResponder];
[self dismissModalViewControllerAnimated:YES];
}
有關詳細信息,請參閱此處的示例代碼檢
http://iosrider.wordpress.com/2012/01/06/how-to-add-email-and-message-in-your-native-application/
可以附加圖像,其他答案提供的測試代碼應該可以工作,但作為第二個來源,位於Apress的相同代碼在此URL 郵件Pic應該能夠幫助您提供一個工作示例。 下載文件夾並打開項目文件的MailPic文件夾。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.