问题描述
我正在使用MFMailComposeViewController从iPhone应用程序发送电子邮件.这可以正常工作,但是在发送或取消后,我需要关闭modalViewController.当我这样做时,我收到程序收到的信号:"EXC_BAD_ACCESS".这不是描述性的...请帮助!
I am sending an email from my iPhone app using MFMailComposeViewController. This works fine but after sending or canceling I need to dismiss the modalViewController. When I do this I get a Program received signal: "EXC_BAD_ACCESS". This is not very descriptive... Please help!!
这是用于创建邮件和modalViewController的代码
This is the code for creating the mail and the modalViewController
-(void)sendFavMail:(NSString *)body{
MFMailComposeViewController* mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
[mailViewController setSubject:@"Favorites List"];
[mailViewController setMessageBody:body isHTML:YES];
[self presentModalViewController:mailViewController animated:YES];
[mailViewController release];
}
这是委托的代码,关闭了modalviewcontroller:
And this is the code for the delegate, dismissing the modalviewcontroller:
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error;
{
switch (result)
{
case MFMailComposeResultCancelled:
NSLog(@"Cancelled sending");
break;
case MFMailComposeResultSaved:
NSLog(@"Message Saved");
break;
case MFMailComposeResultSent:
NSLog(@"Message Sent");
break;
case MFMailComposeResultFailed:
NSLog(@"Sending Failed");
break;
default:
NSLog(@"Message not sent");
break;
}
[self dismissModalViewControllerAnimated:YES];
}
感谢您的帮助!
推荐答案
该死,自己修复:-)
在发送/取消之前,我在邮件正文中释放了一个对象.我要做的就是声明此主体对象已自动释放.那你知道吗可以!
I released an object in the body of the message before sending/cancelling. What I did to fix it is to declare this body object autoreleased. And what do you know? IT WORKS!
就回答了我自己的问题...
Just answered my own question...
这篇关于使用MFMailComposeViewController发送邮件,关闭模式视图控制器时获取"EXC_BAD_ACCESS"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!