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

CKT*_*CKT 3 iphone iphone-sdk-3.0

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

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

objNewViewController = [[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil];
[self.navigationController pushViewController:objNewViewController animated:YES];
Run Code Online (Sandbox Code Playgroud)

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

任何人都可以解决我的问题吗?

Man*_*ath 6

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:[[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil]];

[self presentModalViewController:navigationController               animated:YES];
            [navigationController release];
Run Code Online (Sandbox Code Playgroud)

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

[[self navigationController] dismissModalViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud)