发布MFMAilComposeViewController后presentModalViewController:崩溃
我有以下的代码块,它可以在模拟器和大多数设备上正常工作,但是在某些设备上(全部在相同的iOS版本4.2.1上),应用程序在达到时崩溃[mailComposer release]
调用,有没有人有任何洞察,为什么会发生这种情况?发布MFMAilComposeViewController后presentModalViewController:崩溃
MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;
[mailComposer setSubject:[self.webView stringByEvaluatingJavaScriptFromString:@"document.title"]];
[mailComposer setMessageBody:[NSString stringWithFormat:@"Hello, \n\n Here is the link we discussed. \n %@", [self.webView.request URL]] isHTML:NO];
[self presentModalViewController:mailComposer animated:YES];
[mailComposer release];
行,所以我设法弄清楚是什么造成了我的问题与该问题是由没有引起我的新的iPad 2
的帮助配置任何邮件帐户,只需添加
if ([MFMailComposeViewController canSendMail])
在创建和呈现视图之前,可以防止cr灰化,在我的else
块中,我添加了一个UIAlertView
,让用户知道他们无需先配置邮件帐户即可访问该功能。
我有这个完全相同的问题,我真的不知道为什么它会崩溃,因为presentModalViewController应该保留视图控制器。在与之战斗后,我终于在视图控制器上添加了一个属性,它保留了对mfMailComposeViewController的引用,并且它工作正常。 :/
MFMailComposeViewController* mfMailComposeViewController;
@property (nonatomic, retain) MFMailComposeViewController *mfMailComposeViewController;
然后..
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:subject];
[controller setBody:body];
self.mfMailComposeViewController = controller;
[controller release];
太烂了!并不是说这是一个不好的解决方案,我打算做同样的事情,但这只是跛脚,你必须这样做......对我来说严重没有意义。 – 2011-03-04 19:10:36
完全同意.. – 2011-03-04 19:11:56
Upvoted,要等待看看是否有人可以摆脱更多的光线。 – 2011-03-04 20:45:02
'presentModalViewController'保留它的视图控制器并在弹出时释放它,所以我不知道为什么会导致崩溃。 – 2011-03-04 18:44:52
这也是我的理解,我只是想到了一件事。我使用'showFromBarButtonItem:animated:'在“UIActionSheet”中呈现“电子邮件链接”按钮。当popover被解散并且模态视图正在呈现时,会不会有某种UIKit碰撞? – 2011-03-04 18:48:28