MFMailComposeViewController를 사용하여 내 응용 프로그램에서 메일을 보냅니다. 그러나 현재 메일 작성보기 컨트롤러, 모든 탐색 버튼을 사용할 수 없습니다 (선택 메일 주소 화면에서 뒤로 버튼 제외), 나는 홈 버튼을 사용하여 응용 프로그램을 종료해야합니다. 누구든지 아이디어가 있습니까? 여기 스크린 샷 : MFMailComposeViewController 탐색 모음 단추가 비활성화되었습니다.
코드 :
- (void)shareVieEmail { if ([MFMailComposeViewController canSendMail]) { MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init]; mailViewController.mailComposeDelegate = self; [mailViewController setSubject:@"Test subject"]; [mailViewController setMessageBody:@"Mail message body" isHTML:NO]; NSData *imageData = [NSData dataWithContentsOfFile:photourl]; [mailViewController addAttachmentData:imageData mimeType:@"image/jpg" fileName:@"example_photo"]; [self presentModalViewController:mailViewController animated:YES]; } else { [[[UIAlertView alloc] initWithTitle:@"Cannot send mail" message:@"Device is unable to send email in its current state" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] show]; } }
위임 방법 :
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error { switch (result) { case MFMailComposeResultCancelled: //NSLog(@"Result: canceled"); break; case MFMailComposeResultSaved: //NSLog(@"Result: saved"); break; case MFMailComposeResultSent: { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Result" message:@"Mail Sent Successfully" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show]; } break; case MFMailComposeResultFailed: { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Result" message:@"Mail Sent Failed" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show]; } break; default: //NSLog(@"Result: not sent"); break; } if (error) { [[[UIAlertView alloc] initWithTitle:@"Cannot send mail" message:[NSString stringWithFormat:@"ERROR:%@", [error userInfo]] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] show]; } [self dismissModalViewControllerAnimated:YES]; }
그리고 헤더 파일 , 나는 MFMailCompos을 구현 선언 eViewControllerDelegate.
컨트롤러를 표시하는 데 사용 된 코드를 표시 할 수 있습니까? – mvds
@mvds 코드를 올렸습니다. – youshunei
이상합니다. 괜찮아 보입니다. 이메일 설정과 관련이 있습니까? 모든 기기에서 이렇게 보이나요? – mvds