简体   繁体   English

呈现MFMailComposeViewController,但在可见后立即消失

[英]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.

相关问题 presentModalViewController - ViewController在呈现后自动消失 - presentModalViewController - ViewController automatically disappears after presenting MFMailComposeViewController无法正确显示自己 - MFMailComposeViewController is not presenting itself correctly 从另一个类(MFMailComposeViewController)呈现模态视图 - Presenting a modal view from another class (MFMailComposeViewController) 从iPhone通讯录模态显示MFMailComposeViewController - presenting MFMailComposeViewController modally from iPhone addressbook iOS 7:在navigationController上显示MFMailComposeViewController时出现黑屏 - iOS 7: Blank Screen when presenting MFMailComposeViewController on navigationController 苹果的MFMailComposeViewController中的问题 - problem in apple's MFMailComposeViewController 警告:在视图不在窗口层次结构中的MainViewController上呈现MFMailComposeViewController - warning :presenting MFMailComposeViewController on MainViewController whose view is not in the window hierarchy 在 UIImagePickerController 之后直接调用 MFMailComposeViewController - Call a MFMailComposeViewController Directly After UIImagePickerController MFMailComposeViewController破坏了NavigationController的行为 - MFMailComposeViewController breaks navigationController's behavior 取消MFMailComposeViewController的ActionSheet剪辑 - Cancel MFMailComposeViewController's ActionSheet clipped
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM