简体   繁体   English

导航后栏文字

[英]Navigation back bar text

I have implemented a navigationController from ViewController1 to ViewController2. 我已经实现了从ViewController1到ViewController2的navigationController I am getting the tittle of the ViewController1 in Back BarButton of the NavigationBar at ViewController2. 我在ViewController2的NavigationBar Back BarButton中获得ViewController1的标题。

When i change the tittle of the Back BarButton in the ViewController2 the Tittle in the ViewController1 Changes.? 当我更改ViewController2中Back BarButton的标题时,ViewController1中的标题也会更改。

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

How Can i do that without Changing the Tittle of the ViewController1 如何在不更改ViewController1标题的情况下做到这一点

您应该创建自定义UIBarButtonItem。

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

In ViewController1 在ViewController1中

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

and in ViewController2 并在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)];
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM