SendMailViewController

SendMailViewController

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

我哪里出错了?

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

谢谢,

/ jr00n

- (IBAction)tapExportButton:(id)sender
{

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

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

    [sendMailController release];

}

SendMailViewController:
- (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];}];
}

最佳答案

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

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

确保在关闭MailController之后关闭控制器

10-08 07:31