MFMailComposer Exec_bad_access - 可能与初始化有关

发布于 2024-12-15 13:52:28 字数 1289 浏览 1 评论 0原文

在视图控制器中,我有一个按钮,它在内部调用 IBAction 并在内部调用 now

        [self showEmailModalView:FinalEmail];

... 在我拥有的 showEmailModalView 中

-(void) showEmailModalView:(NSString *)email{

    MFMailComposeViewController *mvc =[[[MFMailComposeViewController alloc] init]autorelease];
    mvc.mailComposeDelegate = self; 

    NSArray *mails = [[NSArray  arrayWithObject:email]autorelease];

    [mvc setToRecipients:mails];

    NSString*emailBody =[NSString stringWithFormat:@" "];

    [mvc setMessageBody:emailBody isHTML:YES]; 

    mvc.navigationBar.barStyle = UIBarStyleBlack; 
    [[self navigationController] presentModalViewController:mvc animated:YES];

}

,然后

-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
 [[self navigationController] dismissModalViewControllerAnimated:YES];
} 

现在它工作正常...对于电子邮件或删除或类似的所有场景,但正确代码完成后,模拟器只是抛出 exec_bad_access 然后什么都不做......你能帮忙吗?

PS:我还发现,当您按照上面声明的方式向 mvc 发布版本时,就会调用错误。蚂蚁的想法。

更新:

我确实安装了应用程序,只进行了一项更改...我在头文件中初始化了 mvc,然后使用相同的语句。所以现在我不再收到 exec_bad_access 错误...我认为它害怕 nsZOMBIES....哈哈...感谢您的帮助和支持..伙计们...你们俩...

In a view controller i have a button which internally calls an IBAction and that internally calls the

        [self showEmailModalView:FinalEmail];

now ... in the showEmailModalView i have

-(void) showEmailModalView:(NSString *)email{

    MFMailComposeViewController *mvc =[[[MFMailComposeViewController alloc] init]autorelease];
    mvc.mailComposeDelegate = self; 

    NSArray *mails = [[NSArray  arrayWithObject:email]autorelease];

    [mvc setToRecipients:mails];

    NSString*emailBody =[NSString stringWithFormat:@" "];

    [mvc setMessageBody:emailBody isHTML:YES]; 

    mvc.navigationBar.barStyle = UIBarStyleBlack; 
    [[self navigationController] presentModalViewController:mvc animated:YES];

}

and then

-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
 [[self navigationController] dismissModalViewControllerAnimated:YES];
} 

Now it works alright... for all the scenarios of email or delete or anything like that but right after completion of the code the simulator just throws a exec_bad_access and then does nothing.... can you help.

PS: i also found out that that when ever you are giving a release to the mvc as declared above the error is called. ant thoughts.

Update:

I did install the app with only one change... i initialized the mvc in the header file and then just use the same statement. so now i am not getting the exec_bad_access errors anymore... i think it was frightened of the nsZOMBIES....Haha... thanks for your Help and support.. guys... Both of you....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪都笑了 2024-12-22 13:52:28

您不应该自动释放此对象,它已经自动释放了:

NSArray *mails = [[NSArray  arrayWithObject:email ]autorelease];

而不是更改为:

NSArray *mails = [NSArray  arrayWithObject:email];

You shouldn't autorelease this object, it's already autoreleased :

NSArray *mails = [[NSArray  arrayWithObject:email ]autorelease];

Instead of change to:

NSArray *mails = [NSArray  arrayWithObject:email];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文