在dismissModalViewController中获取SIGABRT错误

时间:2012-03-25 04:11:07

标签: objective-c ios uiviewcontroller uinavigationcontroller

我取消SIGABRT时收到MFMailComposeViewController错误,完全在dismissViewController,无法正常工作

我在UIViewController内有UINavigationController

我的代码:

- (void)sendMail {
    if ([MFMailComposeViewController canSendMail]) {
        controller = [[MFMailComposeViewController alloc] init];
        [[controller navigationBar] setTintColor:[UIColor getHexColorWithRGB:@"e2de09" alpha:1.0f]];
        controller.mailComposeDelegate = self;
        [controller setSubject:@"Subject"];            

        NSString *msg="xxxxx";
        [controller setMessageBody:msg isHTML:YES];

        [self presentModalViewController:controller animated:YES];

    } else {
        NSString * errorString = [NSString stringWithFormat:@"mail account not set."];

        UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Error:" message:errorString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [errorAlert show];
    }
}

presentModalViewController:animated:正常工作。

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

但是调用[self dissmissModalViewControllerAnimatedLYES]会导致SIGABRT错误。

2 个答案:

答案 0 :(得分:1)

我认为应该在MFMailComposer对象上调用“dismissModalViewControllerAnimated”,在你的情况下是“controller”。请注意,它实际上是一个视图控制器。

答案 1 :(得分:1)

它已经解决了!

我有一个viewWillDisappear:方法,我正在删除视图...

在此之前调用此方法的ModalView和我的ViewController在dissmissModalViewController上已过度发布。

我改变了这个方法。

由于