私のアプリケーションにMFMailComposeViewControllerを実装しています。次のコードを使用してメールコンポーザーを開こうとすると、「キャッチされない例外 'NSInvalidArgumentException'のためにアプリケーションを終了するような例外が発生します。理由: 'アプリケーションがターゲット上にnilモーダルビューコントローラーを表示しようとしました。私は何が悪いのか分かりません。皆さん、私の次のコードを見て、私に提案してください。PresentModalViewControllerを試行すると例外が発生する
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil ];
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate =self ;
controller.delegate=self;
[email protected]"Title";
[controller setSubject:@"See my Notes"];
NSArray* toRecipients=nil;
[controller setToRecipients:toRecipients];
NSString *emailBody = @"";
emailBody = @"<html><head><title><style type=\"text/css\">a {color: red}</style>";
emailBody = [emailBody stringByAppendingString:@"</title></head><body style='background-color: transparent;color:black'> "];
emailBody = [emailBody stringByAppendingString:@"Hello all"];
emailBody = [emailBody stringByAppendingString:@"</body></html>"];
[controller setMessageBody:emailBody isHTML:YES];
[self presentModalViewController:controller animated:YES];
ありがとうございます。 -Sek。