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

查看:104
本文介绍了将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?

推荐答案

你好吗?创建你的模态viewcontroller?只需将控制器包装到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天全站免登陆