本当に奇妙なエラー MFMailCompseViewController が表示されます。エラーは「エラー: オブジェクト ファイル内のセクションを指すセクションがアドレスに含まれていません」です。MFMailCompseViewController が終了し、電子メールが実際に送信されると、アプリがクラッシュします。
これは MFMailComposeViewController に固有のもので、単純な View Controller をモーダルに表示しようとしたところ、問題なく終了しました。
以下は、私が calland present mail composer に書いたコードです:
- (void) emailImage:(UIImage *)img {
//verified that the image is being returned correctly
UIImage *img1 = [[_delegate photoBrowser:self photoAtIndex:0] underlyingImage];
MFMailComposeViewController *mfViewController = [[MFMailComposeViewController alloc] init];
mfViewController.mailComposeDelegate = self;
NSString *subject = @"Check out this photo I took - Cap That App";
[mfViewController setSubject:subject];
NSData *imgData = UIImageJPEGRepresentation(img1, 1.0);
[mfViewController addAttachmentData:imgData mimeType:@"image/jpg" fileName:@"photo.jpg"];
NSString *contactMessage = @"\n\n<a href=\"http://www.agilerocket.com\">Sent via Cap That - Available in the Apple App Store</a>";
[mfViewController setMessageBody:contactMessage isHTML:YES];
[self presentViewController:mfViewController animated:YES completion:nil];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Status:" message:@"" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil] autorelease];
switch (result) {
case MFMailComposeResultCancelled:
alert.message = @"You chose not to send the email.";
break;
case MFMailComposeResultSaved:
alert.message = @"Your email was saved as a draft. It has not been sent yet.";
break;
case MFMailComposeResultSent:
alert.message = @"Your email has been sent!";
break;
case MFMailComposeResultFailed:
alert.message = @"There was an error sending the email. Please verify your email is working and try again.";
break;
default:
alert.message = @"You chose not to send the email.";
break;
}
[self dismissViewControllerAnimated:YES completion:^(void) {
[alert show];
}];
}
これに関する誰かの助けを前もって感謝します。