如何更改在界面生成器中创建的 UINavigationBar 的标题
问题是我在界面生成器中创建了一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在导航栏中使用自定义
titleView
,其中您已添加带有您选择的文本的UILabel
。阅读 Apple 查看 iPhone OS 控制器编程指南文档,了解有关如何自定义导航栏的更多信息。
You could use a custom
titleView
in the navigation bar, in which you have added aUILabel
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.
创建您在界面生成器中创建的 UINavigationBar 的 IBOutlet,
然后更改标题
create un IBOutlet of this UINavigationBar that you created in interface builder
then change title with
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: