我已经创建程序来发送带有我从 sqlite 数据库中的一些详细信息的邮件
如果我不使用附件,它工作正常,但如果我取消注释,就像我得到这样的异常:
Thread 1: EXC_BAD_ACCESS(code=1, address=0x474e5091
这是我的代码:
MFMailComposeViewController *mailView = [[MFMailComposeViewController alloc] init];
mailView.mailComposeDelegate = (id) self;
NSArray *recipients = [NSArray arrayWithObject:@"chintan_zwt@yahoo.com"];
[mailView setToRecipients:recipients];
[mailView setSubject:@"Try Mail From User Application"];
NSString *body = [[NSString alloc] initWithFormat:@"First Name : %@ <br>",lblFirstName.text];
body = [body stringByAppendingFormat:@"Last Name : %@<br>",lblLastName.text];
body = [body stringByAppendingFormat:@"Username : %@<br>",lblUsername.text];
body = [body stringByAppendingFormat:@"Password : %@<br>",lblPassword.text];
body = [body stringByAppendingFormat:@"Birthdate : %@<br>",lblBD.text];
[mailView addAttachmentData:[UIImagePNGRepresentation(u.Img1) bytes]
mimeType:@"image/png"
fileName:@"a.png"];
[mailView setMessageBody:body isHTML:YES];
[self presentModalViewController:mailView animated:YES];
我从数据库中正确获取数据并且能够在屏幕上显示图像但问题只是当我将图像附加到邮件时
在此处
UIImagePNGRepresentation(u.Img1)
U 是用户类(用户定义类)的对象,Img1 是 UIImage 的对象