将 MFMailComposeViewController 推送到导航堆栈上?未以模态方式呈现

2023-06-12移动开发问题
3

本文介绍了将 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代码>.当您尝试将 UINavigationControllerUINavigationController 的子类推送到现有堆栈时,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 推送到导航堆栈上?未以模态方式呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

Cocos2d - 如何检查不同层中对象之间的交集
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)...
2024-08-12 移动开发问题
8

恢复游戏 cocos2d
Resume game cocos2d(恢复游戏 cocos2d)...
2024-08-12 移动开发问题
6

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

如何将 32 位 PNG 转换为 RGB565?
How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)...
2024-08-12 移动开发问题
21

正确的 cocos2d 场景重启?
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)...
2024-08-12 移动开发问题
7