本文介绍了如何更改“后退”的标题?导航栏上的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前左栏按钮的默认值是加载当前一个的视图的标题,换句话说,按下按钮时显示的视图(后退按钮)。
Currently the left bar button default value is the title of the view that loaded the current one, in other words the view to be shown when the button is pressed (back button).
我想将按钮上显示的文本更改为其他内容。
I want to change the text shown on the button to something else.
我尝试将以下代码行放在视图控制器的viewDidLoad方法中但是它似乎不起作用。
I tried putting the following line of code in the view controller's viewDidLoad method but it doesn't seem to work.
self.navigationItem.leftBarButtonItem.title = @"Log Out";
我该怎么办?
谢谢。
推荐答案
这应该放在调用标题为NewTitle的ViewController的方法中。
就在push或popViewController语句之前。
This should be placed in the method that calls the ViewController titled "NewTitle".Right before the push or popViewController statement.
UIBarButtonItem *newBackButton =
[[UIBarButtonItem alloc] initWithTitle:@"NewTitle"
style:UIBarButtonItemStyleBordered
target:nil
action:nil];
[[self navigationItem] setBackBarButtonItem:newBackButton];
[newBackButton release];
这篇关于如何更改“后退”的标题?导航栏上的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!