设置HTML正文时,MFMailComposeViewController在iOS5上崩溃

时间:2011-12-03 14:16:02

标签: html crash ios5 mfmailcomposeviewcontroller

我完全不知所措。我试图让用户通过MFMailComposeViewController发送电子邮件。但是,当我使用HTML正文设置MFMailComposeViewController时,MFMailComposeViewController会正确显示电子邮件,但在发送邮件时,我的应用程序会崩溃,并显示如下日志:

2011-12-03 15:04:08.708 Kinopilot[58387:17503] *** Terminating app due to uncaught
  exception 'DOMException', reason: '*** INVALID_ACCESS_ERR: DOMException 15'
*** First throw call stack:
(0x2994052 0x210fd0a 0x2993f11 0x391affb 0x3886795 0x64a9b4 0x6487b6 
0x648b84 0x648bb4 0x648bb4 0x6424b9 0x69078b 0x658fad 0x658eeb 0x658e6f
0x656d37 0x656bb2 0x65737c 0x65759e 0x658273 0x658758 0x6588e6 0x2995ec9 
0x10965c2 0x12d1d54 0x2995ec9 0x10965c2 0x109655a 0x113bb76 0x113c03f 
0x113b2fe 0x10bba30 0x10bbc56 0x10a2384 0x1095aa9 0x2270fa9 0x29681c5 
0x28cd022 0x28cb90a 0x28cadb4 0x28caccb 0x226f879 0x226f93e 0x1093a9b 0x6680d 0x663d5)

我非常有信心MFMailComposeViewController正确连接,因为当我将主体设置为纯文本时,一切都很好。此外,我的代码在iOS 4.3上使用HTML和纯文本工作正常。

这是相关代码:

@interface MailComposeDelegate: NSObject<MFMailComposeViewControllerDelegate>
@end

@implementation MailComposeDelegate

+(MailComposeDelegate*) sharedMailComposeDelegate
{
  static MailComposeDelegate* mcd = nil;
  if(!mcd) {
    mcd = [[MailComposeDelegate alloc]init];
  }

  return mcd;
}

-(void)mailComposeController:(MFMailComposeViewController*)controller 
          didFinishWithResult:(MFMailComposeResult)result 
                        error:(NSError*)error
{
  [app.window.rootViewController dismissModalViewControllerAnimated:NO];
}

...

@implementation M3AppDelegate(Email)

-(void)composeEmailWithSubject: (NSString*)subject
                       andBody: (NSString*)body
{
  // -- compose HTML message.

  MFMailComposeViewController* mc;
  if([MFMailComposeViewController canSendMail])
    mc = [[MFMailComposeViewController alloc] init];

  if(!mc) return;  

  mc.mailComposeDelegate = [MailComposeDelegate sharedMailComposeDelegate];

  [mc setSubject: subject];
  [mc setMessageBody: body isHTML: YES];

  // -- show message composer.

  [app.window.rootViewController presentModalViewController:mc animated:YES];
}

@end

1 个答案:

答案 0 :(得分:1)

哈,在这里回答我自己的问题:一些iOS5组件不会处理我的一些标记,即

<div style='font-size: 85%'>

DIV。但是,将相对大小更改为绝对像素高度的工作正常。