MFMailComposeViewController

MFMailComposeViewController

本文介绍了将MFMailComposeViewController推送到导航堆栈?没有以模态呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表视图,在其中一个单元格中,它表示联系。选择这个单元格后,我想推入一个MFMailComposeViewController。

I have a table view, and in one of the cells, it says "contact". Upon selecting this cell, I'd like to push in a MFMailComposeViewController.

我似乎只能以模态方式呈现这个MFMailComposeViewController。这有什么问题?

I can only seem to present this MFMailComposeViewController modally. What is the problem here?

谢谢!

相关代码片段:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {


    MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
    //*works*//[self.navigationController presentModalViewController:controller animated:YES];
    //*broken*//[self.navigationController pushViewController:controller animated:YES];

}

我得到的错误是: *由于未捕获的异常而终止应用程序'NSInvalidArgumentException',原因:'不支持推送导航控制器'
*
首次调用堆栈:

The error that I get is: " * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'* Call stack at first throw:"

所以看起来我已经有了一个navigationController,而且由于MFMailComposeViewController是UINavigationController的子类,我将navController推到另一个navController上?

So it looks like I have a navigationController already, and since MFMailComposeViewController is a subclass of UINavigationController, I'm pushing a navController onto another navController?

我希望我的UI保持一致,所以我想将MFMailComposeViewController推送到导航堆栈而不是以模态方式呈现它。

I want my UI to be consistent, so I want to push a MFMailComposeViewController onto the nav stack rather than present it modally.

推荐答案

这是因为 MFMailComposeViewController 不是<$的子类c $ c> UIViewController 但是 UINavigationController 。当您尝试推送 UINavigationController UINavigationController UINavigationController 会引发异常/ code>到现有堆栈上。允许以模态方式呈现 UINavigationController

This is because MFMailComposeViewController isn't a subclass of UIViewController but of UINavigationController. UINavigationController throws an exception when you're attempting to push a UINavigationController or subclass of UINavigationController onto an existing stack. Presenting a UINavigationController modally is permitted.

这篇关于将MFMailComposeViewController推送到导航堆栈?没有以模态呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 00:42