后退按钮不出现在UINavigationController上 [英] Back button not appearing on UINavigationController

查看:140
本文介绍了后退按钮不出现在UINavigationController上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的AppDelegate中设置了UINavigationController:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {          
    // Add the navigation controller's view to the window and display.
    [self.window addSubview:navigationController.view];
    [self.window makeKeyAndVisible];

    return YES;
}

在我的RootViewController中我将另一个视图推入堆栈: / strong>

In my RootViewController I am pushing another view onto the stack:

//Show the deals
    DealViewController *dvc = [[DealViewController alloc] initWithNibName:@"DealViewController" bundle:nil];
    [self.navigationController.navigationBar setHidden:NO];
    [self.navigationController pushViewController:dvc animated:YES];

视图显示,但没有后退按钮添加到我的导航栏。为什么这是我如何解决它?

The view shows up, but there is no back button that is added to my navigation bar. Why is this and how can I resolve it?

推荐答案

您必须将导航控制器视为一堆导航控制器,一屏充满信息。
使用

You must think of the navigation controller as a stack of navigation controllers each controlling one screen full of information. You instantiate the navigation controller with the

-(id)initWithRootViewController:(UIViewController *)rootViewController

方法。在此调用中指定根视图控制器。

method. You specify the root view controller in this call. Then you add the navigation controller's view as a subview to the window, like you did before.

如果你想显示你的第二个屏幕你推动另一个视图控制器在堆栈使用

If you want to show your second screen you push another view controller on the stack by using

-(void)pushViewController:detailViewController animated:YES

方法。

这篇关于后退按钮不出现在UINavigationController上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆