我正在开发一个 iPad 应用程序,该应用程序创建一个 PDF,然后用户从该应用程序通过电子邮件发送。我已经能够成功设置电子邮件以附加 PDF,但我无法让 MFMailComposeViewController 关闭。我已经阅读了关于这个问题的其他几个问题,并试图模仿他们正在做的事情,但邮件撰写者仍然不会解雇。我需要在我的代码中进行哪些更改才能将其关闭?
- (IBAction)submitDailyReportButton:(id)sender {
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc]init];
[mail setMailComposeDelegate:self];
if ([MFMailComposeViewController canSendMail]) {
NSString *email =@"admin@domain.com";
NSArray *emailArray = [[NSArray alloc]initWithObjects:email,nil];
[mail setToRecipients:emailArray];
[mail setSubject:@"Daily Report"];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *newFilePath = [[paths objectAtIndex:0]stringByAppendingPathComponent:@"report.pdf"];
NSData *pdfData = [NSData dataWithContentsOfFile:newFilePath];
[mail addAttachmentData:pdfData mimeType:@"application/pdf" fileName:@"report.pdf"];
NSString *body = @"Please review the attached daily report";
[mail setMessageBody:body isHTML:NO];
[mail setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentViewController:mail animated:YES completion:nil];
}else{
NSLog(@"Message cannot be sent");
}
}