0
我在我的應用程序中實現了MFMailComposeViewController。當我嘗試使用下面的代碼打開郵件編輯器時,我收到異常,如「由於未捕獲的異常'NSInvalidArgumentException'而終止應用程序,原因:'應用程序試圖在目標上呈現一個無模式視圖控制器。我不知道我犯了什麼錯。你們可以看看我的下面的代碼,並建議我。嘗試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。