我正在尝试为我的应用程序实现应用内电子邮件,但我遇到了一个严重的问题。当按下按钮打开应用程序内电子邮件时,它可以正常工作。以下是我遇到的问题:
当我点击取消时,它会要求我保存/删除取消取消的草稿。如果我点击“删除草稿”,操作表就会消失,但邮件编辑器会保持打开状态。我可以与它互动并点按一遍又一遍地发送,它会继续发送电子邮件。但取消按钮无法再与之交互。 “保存草稿”按钮保存了电子邮件的草稿,但作曲家仍处于启动状态,我可以使用取消按钮进行交互。
这是我正在使用的代码:
- (IBAction)sendEmail:(id)sender {
//Set up of e-mail
sendMail = [[MFMailComposeViewController alloc] init];
sendMail.mailComposeDelegate = self;
//Set the subject
[sendMail setSubject:@"Demo attachment"];
//To recipients
NSArray *toRecepients = [[NSArray alloc] initWithObjects:@"exampleEmail@email.com", @"exampleEmail2@email.com", nil];
[sendMail setToRecipients:toRecepients];
//[sendMail setBccRecipients:toRecepients];
//[sendMail setCcRecipients:toRecepients];
//Add message to the body
NSString *emailBody = @"This is a test email with an attachment.\n";
[sendMail setMessageBody:emailBody isHTML:YES];
//Include an attachment
//NSData *pdfData = [NSData dataWithContentsOfFile:@"demo.pdf"];
//[sendMail addAttachmentData:pdfData mimeType:@"file/pdf" fileName:@"Some file"];
[self presentViewController:sendMail animated:YES completion:NULL];
}
在iOS 6上部署应用程序并使用iPhone 5作为测试设备。任何帮助将不胜感激!
答案 0 :(得分:0)
在适当的位置向您的代理人添加[self dismissModalViewControllerAnimated:YES];
。
- (void)mailComposeController:(MFMailComposeViewController*)controllerdidFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
//.. other completion code
[self dismissModalViewControllerAnimated:YES];
}