如何更改在界面生成器中创建的 UINavigationBar 的标题

发布于 2024-09-08 02:28:09 字数 303 浏览 1 评论 0原文

问题是我在界面生成器中创建了一个 UINavigationBar 并且我想更改标题。导航栏未连接到我的 UINavigation 控制器。有什么方法可以让导航栏独立于我的笔尖来完成此操作吗?

我的问题的第二部分更多的是对 UINavigationBars 如何工作的一般理解。我不明白导航项堆栈是如何工作的。例如,如果我想将右侧按钮项目更改为“完成”而不是“编辑”怎么办?我的理解是左、中、右栏按钮项位于堆栈上?但我怎么知道哪个项目位于堆栈中的哪个位置。如果我在这里遗漏了一些基本的东西,我很抱歉,但我需要一些关于如何管理左、中、右栏按钮项目以及堆栈如何工作的澄清。提前致谢。

the issue is that I have created a UINavigationBar in interface builder and I want to change the title. The Navigation bar is not hooked up to my UINavigation controller. Is there any way I can accomplish this with the Navigation Bar as a stand alone from my Nib?

The second part of my question is more a general understanding of how the UINavigationBars work. I don't understand how the stack of navigation items works. for example what if i want to change the right button item to say "done" instead of "edit"? My understanding is that the left, center, and right bar button item are on a stack? but then how do I know which item is at what place in the stack. I'm sorry if I am missing something elementary here but I need some clarification on how the left, center and right bar button items are managed, and how the stack works into this. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

千年*琉璃梦 2024-09-15 02:28:09

您可以在导航栏中使用自定义 titleView,其中您已添加带有您选择的文本的 UILabel

阅读 Apple 查看 iPhone OS 控制器编程指南文档,了解有关如何自定义导航栏的更多信息。

You could use a custom titleView in the navigation bar, in which you have added a UILabel with the text of your choice.

Read the "Configuring the Navigation Item Object" section of Apple's View Controller Programming Guide for iPhone OS documentation for more information on how to customize the navigation bar.

回首观望 2024-09-15 02:28:09

创建您在界面生成器中创建的 UINavigationBar 的 IBOutlet,

@property (weak, nonatomic) IBOutlet UINavigationBar *navigationBar;

然后更改标题

self.navigationBar.topItem.title = @"My Custom Title";

create un IBOutlet of this UINavigationBar that you created in interface builder

@property (weak, nonatomic) IBOutlet UINavigationBar *navigationBar;

then change title with

self.navigationBar.topItem.title = @"My Custom Title";
桃气十足 2024-09-15 02:28:09

UINavigationController 是 UIViewController 的子类,但与 UIViewController 不同,它通常不适合您进行子类化。这是因为除了导航栏的视觉效果之外,导航控制器本身很少进行自定义。

UINavigationController 的实例可以相对轻松地在代码或 XIB 文件中创建。它被认为是一个堆栈:它有一个根视图控制器,然后新的视图控制器可以被推入堆栈(通常当用户点击表中的一行时)或从堆栈中弹出(通常通过按后退按钮) )。

根视图控制器可以通过将视图控制器拖动到导航控制器下来在 XIB 中设置,也可以在创建根视图控制器时使用 initWithRootViewController 在代码中设置。

导航堆栈

四种方法用于在堆栈中导航用户:

– PushViewController:animated:
– popViewControllerAnimated:
– popToRootViewControllerAnimated:
– popToViewController:动画:

UINavigationController is a subclass of UIViewController, but unlike UIViewController it’s not usually meant for you to subclass. This is because navigation controller itself is rarely customized beyond the visuals of the nav bar.

An instance of UINavigationController can be created either in code or in an XIB file with relative ease. It’s thought of as a stack: it has a root view controller, and then new view controllers can be pushed onto the stack (often when the user taps on a row in a table) or popped off the stack (often by pressing the back button).

The root view controller can be set in an XIB by dragging the view controller under the navigation controller, or in code by using initWithRootViewController when you create it.

The Navigation Stack

Four methods are used to navigate user through the stack:

– pushViewController:animated:
– popViewControllerAnimated:
– popToRootViewControllerAnimated:
– popToViewController:animated:

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