1

我正在尝试为我的应用程序实施应用内电子邮件,但遇到了一个严重的问题。当按下按钮打开应用内电子邮件时,它工作得很好。以下是我遇到的问题:

当我点击取消时,它会要求我保存/删除取消取消的草稿。如果我点击“删除草稿”,操作表就会消失,但邮件编辑器会保持打开状态。我可以与它交互并一遍又一遍地点击发送,它会继续发送电子邮件。但是取消按钮不能再交互了。“保存草稿”按钮保存电子邮件的草稿,但作曲家仍在运行,我可以与取消按钮进行交互。

这是我正在使用的代码:

    - (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 作为测试设备。任何帮助,将不胜感激!

4

1 回答 1

0

[self dismissModalViewControllerAnimated:YES];在适当的位置向您的委托添加一个。

- (void)mailComposeController:(MFMailComposeViewController*)controllerdidFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
    //.. other completion code

    [self dismissModalViewControllerAnimated:YES];
}
于 2012-12-18T17:13:52.297 回答