将UINavigationController添加到现有的UIViewController中
问题描述:
如何将现有的UIViewController(使用presentModalViewController呈现)添加到UINavigationController中?将UINavigationController添加到现有的UIViewController中
当用户点击按钮时,需要推送我的详细视图的新副本。 (换句话说,pushViewController以模态方式在UINavigationController中显示pushViewController)。
最简单的方法来启用此功能?
答
你如何创建你的模式视图 - 控制?只是包装控制器到一个UINavigationController
让我们假设你的模式代码是这样的:
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];
答
我认为你需要在你的委托中添加一个导航控制器,之后你可以推动视图。以便您可以从应用程序的任何位置推送视图。
上AppDelegate.hUINavigationController *navig;
上AppDelegate.M
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
navig = [[UINavigationController alloc] initwithRootViewController:viewController.view];
//[navig pushViewController:viewController animated:YES];
[self.window addSubview:navig.view];
[self.window makeKeyAndVisible];
return YES;
}
+0
我无法理解这个问题或者看到这个答案的相关性:)。 – Bogatyr 2011-02-10 14:02:55
目前还不清楚你在问什么。你想以模态方式呈现UINavigationController吗?这“感觉”错了,但我不确定。 – Bogatyr 2011-02-10 14:01:38
这是简化的描述...模态地呈现UINavigationController ...(但是修改现有的UIViewController) – marko 2011-02-10 14:11:40