我在删除模态视图时遇到问题。
我想显示(按下按钮后)我自己的SendMailViewController,它自己显示MFMailComposeViewController。然后在按下取消发送后,在我自己的didFinishWithResult中的SendMailView控制器中,我做了一个[self dismissModalViewControllerAnimated:YES]并且可以正常工作。 MFMailComposeView消失了。
但是屏幕保持黑色......它认为我还必须从它的父节点中删除我的SendMailViewController。这就是我按下按钮的地方......即使在[self removeFromParentViewController]之后它仍然保持黑色......
我哪里出错?
是的,我想要额外的viewcontroller(SendMailViewController),因为该控制器将成为MFMailComposeViewController的委托。否则我的来电者(带按钮的控制器)负有很大的责任。或者我也在这里出错了?
谢谢,
/ 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];}];
}
答案 0 :(得分:3)
问题在于你的didFinishWithResult方法中的[self dismissViewControllerAnimated:YES completion:^{[self removeFromParentViewController];}];
删除该行并添加以下行
[controller dismissViewControllerAnimated:YES completion:^{[self dismissViewControllerAnimated:YES completion:nil]}];
确保在解除MailController
后解除控制器