我有一個與圖像和消息發送電子郵件這個方法..只是在.h文件中添加MFMessageComposeViewControllerDelegate
和項目
-(void)sendMailWithImage:(NSString *)message Image:(UIImage *)image{
if ([MFMailComposeViewController canSendMail])
{
UIImage *tempImageSave=image;
MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
NSString *mailBody = message;
NSData *imageData = UIImagePNGRepresentation(tempImageSave);
[mailComposeViewController addAttachmentData:imageData mimeType:@"image/png" fileName:@"Testing"];
[mailComposeViewController setMessageBody:mailBody isHTML:NO];
mailComposeViewController.mailComposeDelegate = self;
[self presentViewController:mailComposeViewController animated:YES completion:nil];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"e-Mail Sending Alert"
message:@"You can't send a mail"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
}
添加框架MessageUI.framework
這種波紋管的方法是MFMessageComposeViewControllerDelegate
委託方法
#pragma mark - MFMessage Delegate
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
if (result == MFMailComposeResultSent)
{
NSLog(@"\n\n Email Sent");
}
[self dismissViewControllerAnimated:YES completion:nil];
}
我希望這會幫助你...
很抱歉,但聽起來像「我有一個應用程序的想法,但不知道如何做到這一點。的Coul你寫代碼併發送給我?「。不要指望這個問題有任何有用的答案。嘗試一下,用你的腦袋,隨時再問... – tamasgal
@LionKing只需從一個視圖使用此波紋管方法發送帶有MailComposeViewController中的消息和圖像的電子郵件,您可以看到消息和圖像,因此這裏不需要另一個視圖發送電子郵件..看到我的答案咆哮.. –