将UINavigationController添加到现有的UIViewController [英] Adding UINavigationController to existing 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屋!