如何更改后退导航栏按钮项目文本?
我正在开发一个基于导航的应用程序。到目前为止我可以这样做:
self.navigationItem.title=self.Category;
UIBarButtonItem *btnNewGame = [[UIBarButtonItem alloc] initWithTitle:@"New Game" style:UIBarButtonItemStyleBordered
target:self action:@selector(btnNewGameclicked:)];
self.navigationItem.rightBarButtonItem = btnNewGame;
[btnNewGame release];
然后我可以调用选择器提供的方法。从这里开始就没有问题了。
现在发生的是我有左栏按钮项目、标题和右栏按钮项目。
问题
左侧栏按钮项的标题不是 back
,但它似乎与导航项的标题相同。我怎样才能改变这个?有什么建议吗?
谢谢。
I am working on a navigation based application. Until now I am able to do this:
self.navigationItem.title=self.Category;
UIBarButtonItem *btnNewGame = [[UIBarButtonItem alloc] initWithTitle:@"New Game" style:UIBarButtonItemStyleBordered
target:self action:@selector(btnNewGameclicked:)];
self.navigationItem.rightBarButtonItem = btnNewGame;
[btnNewGame release];
and then I can call the method provided by the selector. No problems since here.
What happens now is that I have the left bar button item, the title and the right bar button item.
Problem
The title on the left bar button item is not back
, but it appears to be the same as the navigation item's title. How can I change this? Any suggestions?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
左栏按钮项目的默认行为是显示上一个视图控制器的标题
如果要更改左栏按钮项目上的文本,则需要像这样替换左(后退)按钮
default behaviour of the left bar button item, is to display the title of the previous view Controller
if you want to change the text on the left bar button item, you need to replace the left (back) button like this
根据我理解的您的问题,您的问题是 leftbarbuttonitem 的标题不是后退,这是因为您给了前一个屏幕一些标题。这就是为什么 leftbarbutton 项目显示导航项的标题而不是后退。要删除它您必须删除先前视图的标题或按照马特给出的编程方式执行此操作。
As per your question what i understand , your problem is that the title of leftbarbuttonitem is not Back, this is because you gave the previous screen some title.That's why leftbarbutton item shows the title of navigation-item and not as Back.To remove that you must have erase the title of previous view or do it pro-grammatically as given by Matt.
为什么不呢
?
And why not
?
在
viewDidLoad
方法中尝试这种方式:这对我有用。
Try this way in the
viewDidLoad
method:This worked for me.