내 응용 프로그램에서 전자 메일을 보내려고합니다. 이메일 보내기 창이 열리면 수신자와 본문이 설정되지 않습니다. 나는 모든 필드에 누르려고 할 때마다 그들에게 내 응용 프로그램 충돌을 편집하고 나에게이 오류 제공합니다 :MFMailComposeViewController가 작동하지 않습니다.
***Assertion failure in -[UIKeyboardTaskQueue waituntilalltasksarefinished], /sourcuecache/UIKIt_Sim/UIKit-3318.16.14/KeyboardTaskQueue.m:374 Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only run on the main thread!
내가 이메일 자습서를 살펴 보았습니다을 나는 내가 뭘 잘못 찾을 수 없습니다.
if ([MFMailComposeViewController canSendMail]) {
// Get current date/time
NSDate *date = picker.date;
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc]init];
mailer.mailComposeDelegate = self;
mailer.modalPresentationStyle = UIModalPresentationCurrentContext;
// Set title
NSDateFormatter *dateFmt = [[NSDateFormatter alloc] init];
[dateFmt setDateStyle:NSDateFormatterMediumStyle];
[mailer setSubject:[NSString stringWithFormat:@"test email: sent on %@", [dateFmt stringFromDate:date]]];
// Set recipient
[mailer setToRecipients:@[@"[email protected]"]];
// Set attachment
CGRect r = CGRectMake(0, 0, 200, 200);
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
UIGraphicsBeginImageContextWithOptions(r.size, NO, [UIScreen mainScreen].scale);
else
UIGraphicsBeginImageContext(r.size);
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(UIGraphicsGetCurrentContext(), - mapview.center.x + r.size.width/2.f, - mapview.center.y + r.size.height/2.f);
[mapholder.layer renderInContext:c];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *imageData = UIImagePNGRepresentation(img);
[mailer addAttachmentData:imageData mimeType:@"image/png" fileName:@"map"];
// Set email body
[dateFmt setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
CLLocationCoordinate2D loc = mapview.centerCoordinate;
NSString *emailBody = [NSString stringWithFormat:@"BRO it is Time: %@\n Location: %f,%f", [dateFmt stringFromDate:date], loc.latitude, loc.longitude];
[mailer setMessageBody:emailBody isHTML:NO];
[self presentViewController:mailer animated:YES completion:nil];
}
및
-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
[self dismissModalViewControllerAnimated:YES];
}
주 – pudm