[英]Presenting MFMailComposeViewController, but it disappears right after it's visible
The first ViewController in my app subclasses UIImagePickerController and then through the didFinishPickingMediaWithInfo callback, I do the following: 我应用程序中的第一个ViewController子类化UIImagePickerController,然后通过didFinishPickingMediaWithInfo回调,执行以下操作:
EditViewController *editViewController = [[EditViewController alloc] initWithNibName:@"EditViewController" bundle:nil];
[self pushViewController:editViewController animated:YES];
this ViewController displays properly... Then, through an IBAction, I do the following: 该ViewController正确显示...然后,通过IBAction,我执行以下操作:
PreviewViewController *previewViewController = [[PreviewViewController alloc] initWithNibName:@"PreviewViewController" bundle:nil];
previewViewController.tempImage = img;
[self.navigationController pushViewController:previewViewController animated:YES];
This view also displays correctly. 此视图也可以正确显示。 In this VC I'm trying to use the MFMailComposeViewController for sending an email.
在此VC中,我尝试使用MFMailComposeViewController发送电子邮件。 When I attempt to push it, I get Pushing a navigation controller is not supported :
当我尝试将其推入时,将显示“不支持推入导航控制器” :
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
[mailViewController setSubject:@"Subject Goes Here."];
[mailViewController setMessageBody:@"Your message goes here." isHTML:NO];
[self.navigationController pushViewController:mailViewController animated:YES];
But when I present it instead: 但是当我提出它时:
[self presentModalViewController:mailViewController animated:YES];
The mailViewController appears for only a second and then disappears and I see a black background (but not the previous VC's view) with an empty navbar on top. mailViewController仅出现一秒钟,然后消失,我看到黑色的背景(但不是以前的VC的视图),顶部有一个空白的导航栏。 The app is still running at this point.
该应用程序此时仍在运行。
What am I doing wrong? 我究竟做错了什么?
If you still want to push the mailViewController you can do this (iOS 7 only): 如果您仍要推送mailViewController,则可以执行此操作(仅适用于iOS 7):
UIViewController *theMailViewController = [[mailViewController viewControllers] lastObject];
[self.navigationController pushViewController:theMailViewController animated:YES];
That way the MailViewController's rootViewController will get pushed into your actual navigationController. 这样,MailViewController的rootViewController将被推送到您的实际NavigationController中。
I hope this helps you. 我希望这可以帮助你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.