我正在开发一个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");
}
Run Code Online (Sandbox Code Playgroud)
}