我有一个表格视图,在其中一个单元格中显示联系人".选择此单元格后,我想推入一个 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:"
所以看起来我已经有了一个导航控制器,并且由于 MFMailComposeViewController 是 UINavigationController 的子类,我正在将一个导航控制器推到另一个导航控制器上?
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
不是 UIViewController
的子类,而是 UINavigationController
代码>.当您尝试将 UINavigationController
或 UINavigationController
的子类推送到现有堆栈时,UINavigationController
会引发异常.允许以模态方式呈现 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 推送到导航堆栈上?未以模态方式呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!