如何以编程方式添加导航控制器?

问题描述 投票:3回答:2

在我的应用程序中有要求..我在笔尖中有6个按钮,当我按任意按钮时,根据按下的按钮将新的笔尖加载到窗口中。问题是加载新笔尖后如果我想回到前一个笔尖(有所有按钮)如何添加导航控制器?

我现在正在做的是在按下按钮时加载新笔尖

objNewViewController = [[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil];
[self.navigationController pushViewController:objNewViewController animated:YES];

但通过这种方式,我无法加载笔尖,它没有执行任何操作?

iphone iphone-sdk-3.0
2个回答
6
投票
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:[[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil]];

[self presentModalViewController:navigationController               animated:YES];
            [navigationController release];

在NewViewController中:使用它来解雇并返回上一个视图。

[[self navigationController] dismissModalViewControllerAnimated:YES];

0
投票

Xcode中有一个基于导航的应用程序的模板。它完成了你描述的一切。嗯,至少非常接近,只有AnotherViewController中的-tableView:didSelectRowAtIndexPath:被注释掉了。

© www.soinside.com 2019 - 2024. All rights reserved.