3

我在删除模态视图时遇到问题。我想显示(按下按钮后)我自己的 SendMailViewController,它自己显示 MFMailComposeViewController。然后,在按下取消发送后,在我自己的 SendMailView 控制器中的 didFinishWithResult 中,我做了一个 [self dismissModalViewControllerAnimated:YES] 并且有效。MFMailComposeView 消失了。
但是然后屏幕保持黑色......它认为我还必须从它的父级中删除我的 SendMailViewController。那就是我按下按钮的地方......即使在 [self removeFromParentViewController] 之后它仍然保持黑色......

我哪里错了?

是的,我想要额外的视图控制器(SendMailViewController),因为该控制器将成为 MFMailComposeViewController 的代表。否则我的调用者(带有按钮的控制器)将承担很多责任。还是我在这里也出错了?

谢谢,

/jr00n

- (IBAction)tapExportButton:(id)sender
{

    SendMailViewController *sendMailController = [[SendMailViewController alloc]init];

    [self presentViewController:sendMailController animated:YES completion:^()    {[sendMailController openMailDialog];}];

    [sendMailController release];

}

发送邮件视图控制器:

- (void)openMailDialog
{
    if ([MFMailComposeViewController canSendMail])
    {
        MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
        mailer.mailComposeDelegate = self;
     ...
        [self presentModalViewController:mailer animated:YES];
    }
}


- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
....
 // Remove the mail view
 // first i did this:
 // [self dismissModalViewControllerAnimated:YES];

    [self dismissViewControllerAnimated:YES completion:^{[self removeFromParentViewController];}];
}
4

1 回答 1

3

问题出[self dismissViewControllerAnimated:YES completion:^{[self removeFromParentViewController];}];在您的 didFinishWithResult 方法中。
删除该行并添加以下行,

[controller dismissViewControllerAnimated:YES completion:^{[self dismissViewControllerAnimated:YES completion:nil]}];

确保我们在关闭 MailController 后关闭控制器

于 2013-05-04T05:34:32.623 回答