更改“返回” Monotouch 中的导航项文本?

发布于 2024-10-30 02:20:34 字数 674 浏览 0 评论 0原文

是否可以更改 NavigationItem 中的“后退”按钮文本?目前,后退按钮的标题采用导航堆栈中上一层的标题,这是预期的。

但是,可以使用如下代码更改 NavigationItemLeftBarButtonItem

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暗恋未遂 2024-11-06 02:20:34

设置前一个视图控制器导航项的标题。我之前回答过这个问题,并会查找链接。

啊,是的:导航栏和导航按钮中的单独标题

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文