1

我的代码中显然遗漏了一些东西,因为每当我尝试按“发送”或“取消”时,应用程序都会崩溃。另外,我有一个固定的主题和收件人,但如果我尝试编辑它们,应用程序就会崩溃。任何帮助,将不胜感激。这是我当前与 MFMailComposeViewController 相关的代码:

MFMailComposeViewController *controller = [[[MFMailComposeViewController alloc] init] autorelease];
    controller.hidesBottomBarWhenPushed = YES;
    controller.mailComposeDelegate = self;
    [controller setToRecipients:[NSArray arrayWithObject:@"BSCApp@ymail.com"]];
    [controller setSubject:@"My Subject"];
    if (controller) [self presentModalViewController:controller animated:YES];
    [controller release];

和...

- (void)mailComposeController:(MFMailComposeViewController*)controller  
      didFinishWithResult:(MFMailComposeResult)result 
                    error:(NSError*)error;
{
    if (result == MFMailComposeResultSent) {
        NSLog(@"It's away!");
    }
    [self dismissModalViewControllerAnimated:YES];
 }

提前致谢。

4

1 回答 1

2

你有autoreleaserelease在同一个实例上,所以你过度释放它,后来当你尝试用它做任何事情时,你会因为访问僵尸对象而崩溃。

autorelease从第一行删除消息就可以了。

于 2012-04-15T18:59:58.857 回答