Pushing an MFMailComposeViewController onto the navigation stack? Not presented modally(将 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:"
所以看起来我已经有了一个导航控制器,并且由于 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 推送到导航堆栈上?未以模态方式呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 MFMailComposeViewController 推送到导航堆栈上?未以模态方式呈现
基础教程推荐
- 更改 UITableView 部分标题的颜色 2022-01-01
- 从 UIWebView 访问元数据 2022-01-01
- Firebase 云消息传递令牌未生成 2022-01-01
- UINavigationBar 隐藏按钮文本 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- EditText 中的 setHintTextColor() 2022-01-01
- 在 iOS 7 下 CCMenu 错位 2022-01-01
- Android - 如何在runOnUiThread 中将数据传递给Runnable? 2022-01-01
- 在视图控制器的宽度上水平均匀分布 UIButton 的最简单方法? 2022-01-01
- UINavigationItem 的持久 rightBarButtonItem 属性 2022-01-01