iphone - 如何使用当前 View 信息自定义 UINavigationController 的顶部栏?

标签 iphone cocoa-touch ios

我有一个 UINavigationController,在图片中您可以看到添加了一个 UIViewController。

现在,我想用当前可见的 UIViewController 的内容自定义 UINavigationController 的顶部栏。更具体地说,我想:

  1. 添加标题
  2. 自定义“后退”按钮文本

我应该使用当前 UINavigationController 中的 self.navigationController 方法吗?如果是,下一步是什么?

谢谢 enter image description here

最佳答案

您可以设置标题:

[[self navigationItem] setTitle:@"title text"];

您可以在 InterfaceBuilder 中更改后退按钮文本或:

[[[self navigationItem] backBarButtonItem] setTitle:@"back button text"];

但请记住,backBarButtonItem 来自之前的 ViewController,因此您必须将其设置在那里。或者,标题是从上一个 View 设置的。

关于iphone - 如何使用当前 View 信息自定义 UINavigationController 的顶部栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5803163/

相关文章:

java - 超声波通讯

iphone - 使用 VBO 上传后更改顶点的颜色

ios - 对保留原始索引而不是值的 NSArray 进行排序

ios - 如何将 Cocoa Touch 静态库链接到 MonoTouch 项目?

ios - 覆盖 View ,但将输入向下传播到最低 z-index

ios - 在 Swift 中返回 self

ios - iOS 中跨不同 Size 类别的 Segment Bar

iphone - 通过添加实例变量来扩展现有类

ios - 在 dealloc 中使 NSTimer 失效

ios - 类的多重继承