将 UINavigationController 添加到现有的 UIViewController [英] Adding UINavigationController to existing UIViewController

查看:43
本文介绍了将 UINavigationController 添加到现有的 UIViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将现有的 UIViewController(使用 presentModalViewController 呈现)添加到 UINavigationController?

How do I add an existing UIViewController (which is presented using presentModalViewController) to a UINavigationController?

当用户点击按钮时,需要推送我的详细信息视图的新副本.(换句话说,pushViewController 在 UINavigationController 中模态地显示 pushViewController).

When user tap on button, a new copy of my detail view need to be pushed. (In other words, pushViewController displaying pushViewController, modally, in a UINavigationController).

启用此功能的最简单方法是什么?

Easiest way to enable this functionality?

推荐答案

你如何创建你的模态视图控制器?只需将控制器包装成 UINavigationController

how do you create your modal viewcontroller? Just wrap the controller into a UINavigationController

假设你的模态代码是这样的:

Let's assume your modal code is like this:

MyExampleViewController *vc = [[[MyExampleViewController alloc] initWithNibName:@"MyExample" bundle:nil] autorelease];
[self presentModalViewController:vc animated:YES];

然后把它改成这样:

MyExampleViewController *vc = [[[MyExampleViewController alloc] initWithNibName:@"MyExample" bundle:nil] autorelease];
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:vc] autorelease];
[self presentModalViewController:navController animated:YES];

这篇关于将 UINavigationController 添加到现有的 UIViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆