繁体   English   中英

导航后栏文字

[英]Navigation back bar text

我已经实现了从ViewController1到ViewController2的navigationController 我在ViewController2的NavigationBar Back BarButton中获得ViewController1的标题。

当我更改ViewController2中Back BarButton的标题时,ViewController1中的标题也会更改。

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

如何在不更改ViewController1标题的情况下做到这一点

您应该创建自定义UIBarButtonItem。

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

在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)];
    }

暂无
暂无

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

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