MFMailComposer Exec_bad_access - 可能与初始化有关
在视图控制器中,我有一个按钮,它在内部调用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不应该自动释放此对象,它已经自动释放了:
而不是更改为:
You shouldn't autorelease this object, it's already autoreleased :
Instead of change to: