我在删除模态视图时遇到问题。
我想显示(按下按钮后)我自己的 SendMailViewController,它自己显示 MFMailComposeViewController。然后在按下取消发送后,在我自己的 SendMailView Controller 中的 didFinishWithResult 中,我做了一个 [self dismissModalViewControllerAnimated:YES] 并且有效。 MFMailComposeView 消失了。
但是随后屏幕保持黑色....它认为我还必须从它的父级中删除我的 SendMailViewController。这就是我按下按钮的地方......即使在 [self removeFromParentViewController] 之后它仍然保持黑色......
我哪里出错了?
是的,我想要额外的 View Controller (SendMailViewController),因为该 Controller 将成为 MFMailComposeViewController 的委托(delegate)。否则我的调用者(带按钮的 Controller )将承担很大的责任。还是我这里也出错了?
谢谢,
/jr00n
- (IBAction)tapExportButton:(id)sender
{
SendMailViewController *sendMailController = [[SendMailViewController alloc]init];
[self presentViewController:sendMailController animated:YES completion:^() {[sendMailController openMailDialog];}];
[sendMailController release];
}
发送邮件 View Controller :
- (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 之后关闭 Controller
关于ios - 从父屏幕中删除 ViewController 保持黑色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16370694/