4
나는 사용자가 응용 프로그램에서 전자 메일로 보내는 PDF를 만드는 iPad 응용 프로그램에서 작업하고 있습니다. PDF를 첨부하기 위해 전자 메일을 성공적으로 설정할 수 있었지만 MFMailComposeViewController를 닫을 수 없습니다. 나는이 문제에 관한 몇 가지 다른 질문을 읽고 그들이하고있는 것을 모방하려고 시도했지만 메일 작곡가는 여전히 기각하지 않을 것이다. 해고 할 수 있도록 코드에서 무엇을 변경해야합니까?인앱 이메일 중 MFMailComposeViewController를 닫지 않는 이유는 무엇입니까?
- (IBAction)submitDailyReportButton:(id)sender {
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc]init];
[mail setMailComposeDelegate:self];
if ([MFMailComposeViewController canSendMail]) {
NSString *email [email protected]"[email protected]";
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");
}
}
정말 고마워요! 그것은 올바르게 작동합니다. – user2330744
BTW - 이것은 'MFMailComposeViewControllerDelegate' 참조에 설명되어 있습니다. – rmaddy