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

查看:15
本文介绍了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 中,我将另一个视图推入堆栈:

//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天全站免登陆