更改“返回” Monotouch 中的导航项文本?
是否可以更改 NavigationItem
中的“后退”按钮文本?目前,后退按钮的标题采用导航堆栈中上一层的标题,这是预期的。
但是,可以使用如下代码更改 NavigationItem
的 LeftBarButtonItem
:
UIBarButtonItem backButton = new UIBarButtonItem("Back", UIBarButtonItemStyle.Plain, null);
myNewView.NavigationItem.SetLeftBarButtonItem(backButton, true);
这可以工作,并且后退按钮按预期显示,但该按钮是方形的,并且不显示。按预期导航回上一层。我猜测需要为其分配正确的事件,但我不知道它应该是什么。
如何确保新的 UIBarButtonItem 具有正确的事件和箭头形状?
注意:我还尝试按照此SO问题,但我仍然不知道如何自定义按钮标题。我可能只是错过了显而易见的事情。
谢谢!
Is it possible to change the "Back" button text in a NavigationItem
? At present, the caption of the back button assumes the title of the previous layer in the navigation stack, which is expected.
However, the NavigationItem
's LeftBarButtonItem
can be changed using code such as this:
UIBarButtonItem backButton = new UIBarButtonItem("Back", UIBarButtonItemStyle.Plain, null);
myNewView.NavigationItem.SetLeftBarButtonItem(backButton, true);
This works and the back button is displayed as expected, but the button is a square and does not navigate back to the previous layer as expected. I'm guessing that the correct event needs to be assigned to it, but I have no idea what it should be.
How would one go about ensuring that the new UIBarButtonItem
has the correct event and arrow shape?
Note: I have also tried re-using the `LeftBarButtonItem' as suggested in this SO question, but I still don't know how to customize the button caption. I am probably just missing the obvious.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设置前一个视图控制器导航项的标题。我之前回答过这个问题,并会查找链接。
啊,是的:导航栏和导航按钮中的单独标题
Set the title on the previous viewcontrollers navigationitem. I answered this before and will look up the link.
Ah, yes: Separate title in NavigationBar and navigation buttons