可能重复:
如何更改“back” 的标题导航栏上的按钮
情况:
我有一个由导航控制器管理的 UIViewController.我可以通过简单地调用 self.title = @"title"
来设置覆盖 UIViewController 的导航栏的 title.但是,我也希望能够设置导航栏的后退按钮文本(对于不同的语言,例如......)
问题:
我不知道如何设置后退按钮的文字.
问题:
如何设置 UINavigation 栏的后退按钮(编程方式不在 IB 中)?
setTitle 方式 - 虽然看起来可行,但不正确.如果您仔细观察,您会注意到导航项更改为新标题,而新视图通过 pushViewController 动画进入视图.您必须在 viewWillAppear 中恢复您的标题这一事实很笨拙,这进一步表明了它的黑客性质.
正确的做法是在你的pushViewController之前做如下操作:
<上一页>UIBarButtonItem *backButton = [[UIBarButtonItem alloc]initWithTitle: @"返回按钮文本"样式:UIBarButtonItemStyleBordered目标:无行动:无];[self.navigationItem setBackBarButtonItem: backButton];[返回按钮释放];Possible Duplicate:
How do I change the title of the “back” button on a Navigation Bar
The Situation:
I have a UIViewController that is governed by a navigation controller. I am able to set the title of the navigation bar covering the UIViewController by simply calling self.title = @"title"
. But, I want to be able to set the back button text of the navigation bar, too (for different languages n' such..)
The Problem:
I don't know how to set the back button's text.
The Question:
How do I set the back button of the UINavigation bar (programmatically not in IB)?
The setTitle way - though may seem to work, is incorrect. If you pay attention closely, you will notice that the navigation item changes to the new title while the new view is animated into view via pushViewController. The fact that you have to restore your title in viewWillAppear is kludgy, which further suggests its hack nature.
The correct way is to do the following before your pushViewController:
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle: @"Back Button Text" style: UIBarButtonItemStyleBordered target: nil action: nil]; [self.navigationItem setBackBarButtonItem: backButton]; [backButton release];
这篇关于如何在 UINavigationBar 上设置后退按钮的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!