尝试从iPhone发送电子邮件时,MFMailComposeViewController崩溃

时间:2014-06-02 07:35:04

标签: ios iphone mfmailcomposeviewcontroller

我正在使用Note创建ARC种应用程序,用户可以通过电子邮件分享他的笔记。我的问题是当我提出MFMailComposeViewController然后应用程序崩溃时出现以下错误:

*** Assertion failure in NSDictionary *_UIRecordArgumentOfInvocationAtIndex(NSInvocation *, NSUInteger, BOOL)(), /SourceCache/UIKit/UIKit-2380.17/UIAppearance.m:1118

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unknown key, "NSColor" in title text attributes dictionary'

代码如下:

if ([MFMailComposeViewController canSendMail])
        {
            MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
            picker.mailComposeDelegate = self;

            NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
            NSString *strSubject = [NSString stringWithFormat:@"A Note from %@", [prefs stringForKey:@"strAppTitle"]];

            [picker setSubject:strSubject];

            NSString *emailBody = strNoteText;
            [picker setMessageBody:emailBody isHTML:NO];

            [self presentViewController:picker animated:YES completion:nil];
        }

我已经实施了MFMailComposeViewControllerDelegate协议。你能否告诉我任何我做错的地方?感谢

1 个答案:

答案 0 :(得分:1)

你已经将'strNoteText'作为MessageBody,检查它是否为空