1
모달보기 컨트롤러에서 MFMailComposeViewController
을 표시하려고합니다. 기본적으로이 방법은 작동하지만 안정적으로 작동하지 않습니다MFMailComposeViewController는 두 번째 탭 이후에만 표시됩니다.
-(void)sendMailTapped:(id)sender{
[self resetButtonsStateAfterTapping:sender];
[self dismissPopover];
if (filesize>10) {
[self showAlertForExceededMaximumAttachmentSize];
return;
}
@try {
MFMailComposeViewController *picker =
[[MFMailComposeViewController alloc] init];
if ([MFMailComposeViewController canSendMail]) {
picker.mailComposeDelegate = self;
NSURL *path =[NSURL urlWithPath:[pageInfoDict valueForKey:@"file_name"]
docId:[pageInfoDict valueForKey:@"id_doc"]
encrypted:[[pageInfoDict valueForKey:@"encrypted"]
boolValue]] ;
NSString *fileName = [pageInfoDict valueForKey:@"title"];
if([fileName length] == 0) {
fileName = [path lastPathComponent];
}
if(![fileName hasSuffix:[path pathExtension]]){
fileName=[fileName stringByAppendingFormat:@".%@",[path pathExtension]];
}
[picker setSubject:[@"Send document: " stringByAppendingString:fileName]];
NSArray *ccRecipients = [NSArray arrayWithObjects:
[[CustomisationConfig getAppConfig] getCCMail],nil];
[picker setCcRecipients:ccRecipients];
NSArray *bccRecipients = [NSArray arrayWithObjects:
[[CustomisationConfig getAppConfig] getBCCMail],nil];
[picker setBccRecipients:bccRecipients];
NSData *myData = [path decryptedData];
[picker addAttachmentData:myData
mimeType:fileMIMEType(fileName) fileName:fileName];
NSString *emailBody = [NSString stringWithFormat:
@"\n\nThis file was sent using %@.",
[DCConfiguration getHumanReadableAppName] ];
[picker setMessageBody:emailBody isHTML:NO];
[self presentViewController:picker animated:true completion:^(void){}];
}
}
@catch (NSException *exception) {
NSLog(@"ContextMenuViewController sendMailTapped:%@",exception.description);
}
}
내 아이 패드를 다시 시작하고 응용 프로그램을 열 경우는, 피커은 해당 버튼의 두 번째 탭에 표시됩니다.
이 버튼을 다시 클릭하면 매번 처음으로 피커가 표시되며 iPad를 종료하고 다시 시작할 때까지 완벽하게 작동합니다.
다음은 콘솔에 인쇄 된 다음 sendMailTapped:
메소드를 호출 무엇
Warning: Attempt to present <MFMailComposeViewController: 0x200cbb70> on <ContextMenuViewController: 0x200cd1a0> whose view is not in the window hierarchy!
sendMailTapped 메소드 시작 부분에서 dismissPopOver를 호출해야하는 이유는 무엇입니까? –