导航回栏文本

时间:2016-06-27 08:38:49

标签: ios

我已经从ViewController1到ViewController2实现了navigationController。我在ViewController2的NavigationBar Back BarButton 中得到了ViewController1的一小部分。

当我在ViewController2中更改 Back BarButton 的tittle时,ViewController1中的Tittle会发生变化。?

self.navigationController.navigationBar.topItem.title = @"";
self.navigationController.navigationBar.backItem.title = @"";

如何在不改变ViewController1的Tittle的情况下做到这一点

2 个答案:

答案 0 :(得分:0)

您应该创建自定义UIBarButtonItem。

self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Your Title" style:UIBarButtonItemStylePlain target:self action:YOUR_SELECTOR] autorelease];

答案 1 :(得分:0)

在ViewController1中

-(void)viewWillAppear:(BOOL)animated {
       [super viewWillAppear:animated];
       self.navigationItem.title = @"someTitle1";
}

并在ViewController2中

-(void)viewWillAppear:(BOOL)animated {
       [super viewWillAppear:animated];
       self.navigationItem.title = @"someTitle2";
       self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
       initWithImage:[UIImage imageNamed:@"BACK_BUTTON_IMG.png"] style:UIBarButtonItemStylePlain 
       target:self action:@selector(YOUR_SELECTOR_METHOD)];
    }