【问题标题】:iOS: UINavigationBar title doesn't appeariOS:UINavigationBar 标题不出现
【发布时间】:2012-10-29 11:43:44
【问题描述】:

我不确定我的 UINavigationBar 标题出了什么问题。在尝试了所有可能的事情后,我无法让它工作。出现导航栏但标题不见了!!这是我的简单代码,

self.marketsListViewController = [[MarketsListViewController alloc] initWithNibName:@"MarketsListViewController" bundle:nil];
UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:self.marketsListViewController];
nvc.navigationBar.barStyle = UIBarStyleBlack;
[self.marketsListView addSubview:nvc.view];
[self addChildViewController:nvc];
[nvc didMoveToParentViewController:self];

在 MarketsListViewController 的 didViewLoad 中,我尝试了所有以下方法,但都没有成功!!!有人可以帮我理解发生了什么吗?谢谢。

self.title = @"MyTitle";
self.navigationItem.title = @"MyTitle";
self.navigationController.navigationItem.title = @"MyTitle";

【问题讨论】:

    标签: ios5 uinavigationcontroller uinavigationbar title uinavigationitem


    【解决方案1】:

    iOS6 的 UINavigationController 似乎有一些变化。

    https://stackoverflow.com/a/13205842/1171003

    当我写这样的代码时,标题根本没有显示。

    UITabBarController *tb = [[UITabBarController alloc] init];
    tb.viewControllers = [NSArray arrayWithObjects:
                           [[ViewController1 alloc] init],
                           [[ViewController2 alloc] init],
                           nil];
    
    UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:tb];
    

    但是,在我添加了这一行之后,它就出现了。

    tb.title = @"Title";
    

    【讨论】:

      猜你喜欢
      • 2021-08-31
      • 2016-01-04
      • 1970-01-01
      • 2015-12-23
      • 1970-01-01
      • 2020-08-13
      • 2015-11-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多