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 推送到导航堆栈上?未以模态方式呈现
基础教程推荐
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
