(ios6.1)有两个controller在navigation stack里,A和B。A是B的previous view controller,现在top-level controller是B。要自定义B的backBarButtonItem。

在B的viewDidLoad里添加:

     //chage navigationBarButton
UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"房间选择" style:UIBarButtonItemStyleDone target:nil action:nil];
[self.navigationItem setBackBarButtonItem:backButtonItem];

试了,结果还是默认的back按钮。

UINavigationController Class Reference中有段话:

The bar button item on the left side of the navigation bar allows for navigation back to the previous view controller on the navigation stack. The navigation controller updates the left side of the navigation bar as follows:

  • If the new top-level view controller has a custom left bar button item, that item is displayed. To specify a custom left bar button item, set the leftBarButtonItem property of the view controller’s navigation item.
  • If the top-level view controller does not have a custom left bar button item, but the navigation item of the previous view controller has a valid item in itsbackBarButtonItem property, the navigation bar displays that item.
  • If a custom bar button item is not specified by either of the view controllers, a default back button is used and its title is set to the value of the title property of the previous view controller—that is, the view controller one level down on the stack. (If there is only one view controller on the navigation stack, no back button is displayed.)
  • 1、如果B视图有一个自定义的左侧按钮(leftBarButtonItem),则会显示这个自定义按钮;

    2、如果B没有自定义按钮,但是A视图的backBarButtonItem属性有自定义项,则显示这个自定义项;

    3、如果前2条都没有,则默认显示一个后退按钮,后退按钮的标题是A视图的标题,或者默认

try again,在A中的ViewDidLoad中定义backButtonItem:

     //chage navigationBarButton
UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"房间选择" style:UIBarButtonItemStyleDone target:nil action:nil];
[self.navigationItem setBackBarButtonItem:backButtonItem];

发现B中的backBarButtonItem改变了!!!

如果在B中custom一个UIbarButtonItem,赋值给self.navigationItem.leftBarButtonItem,那么这个UIBarButtonItem将替换backBarButtonItem按钮。

关于Navigation的BarButtonItem的的更多相关文章

  1. WPF仿Word头部格式,涉及DEV RibbonControl,NarvbarControl,ContentPresenter,Navigation

    时隔1个月,2015/06/17走进新的环境. 最近一个星期在学习仿Word菜单栏的WPF实现方式,废话不多说,先看一下效果. 打开界面后,默认选中[市场A],A对应的菜单栏,如上图, 选择[市场B] ...

  2. arcgis api for js共享干货系列之二自定义Navigation控件样式风格

    arcgis api for js默认的Navigation控件样式风格如下图: 这样的风格不能说不好,各有各的爱好,审美观,这里也不是重点,这里的重点是如何自定义一套自己喜欢的样式风格呢:自己自定义 ...

  3. The Safe Navigation Operator (&.) in Ruby

    The most interesting addition to Ruby 2.3.0 is the Safe Navigation Operator(&.). A similar opera ...

  4. Unity3D 导航网格自动寻路(Navigation Mesh)

    NavMesh(导航网格)是3D游戏世界中用于实现动态物体自动寻路的一种技术,将游戏中复杂的结构组织关系简化为带有一定信息的网格,在这些网格的基础上通过一系列的计算来实现自动寻路..导航时,只需要给导 ...

  5. ABP理论学习之导航(Navigation)

    返回总目录 本篇目录 创建菜单 注册导航提供者 展示菜单 每一个web应用在页面之间都有一些要导航的菜单.ABP提供了公用的基础设施来创建菜单并将菜单展示给用户. 创建菜单 一个应用可能由不同的模块组 ...

  6. Sharepoint学习笔记—ECM系列—文档列表的Metedata Navigation与Key Filter功能的实现

    如果一个文档列表中存放了成百上千的文档,想要快速的找到你想要的还真不是件容易的事,Sharepoint提供了Metedata Navigation与Key Filter功能可以帮助我们快速的过滤和定位 ...

  7. iOS第八课——Navigation Controller和Tab bar Controller

    今天我们要学习Navigation Controller和Tab bar Controller. Navigation Controller是iOS编程中比较常用的一种容器,用来管理多个视图控制器. ...

  8. navigation和tabbar上的文字.图片 自定义

    [[UITabBarItem appearance] setTitleTextAttributes:@{ UITextAttributeTextColor : [UIColor blackColor] ...

  9. navigation controller

    一.程序框架 1.程序结构

随机推荐

  1. JSch - Java实现的SFTP(文件上传详解篇)

    JSch是Java Secure Channel的缩写.JSch是一个SSH2的纯Java实现.它允许你连接到一个SSH服务器,并且可以使用端口转发,X11转发,文件传输等,当然你也可以集成它的功能到 ...

  2. 分模块创建maven项目(一)

    maven是一个项目构建和管理的工具. 我们可以通过maven仓库可以实现管理构建(主要是JAR还包括:WAR,ZIP,POM等等). 我们可以通过maven插件可以实现编译源代.产生Javadoc文 ...

  3. javaweb之框架标签(day1 框架标签的使用)

    框架标签 <frameset> --rows:按照行进行划分<frameset rows='80,*'> --rows:按照列进行划分<frameset cols='80 ...

  4. win7 、win10连接l2tpvpn

    win7:  修改vpn连接选项: win10: 参考连接: http://service.njaf.gov.cn/26970/26971/201510/t20151024_3621861.html ...

  5. .net 文件下载【转】

    方式一:TransmitFile实现下载.将指定的文件直接写入 HTTP 响应输出流,而不在内存中缓冲该文件.     protected void Button1_Click(object send ...

  6. 新广告法,极限词剔除,替换掉的mysql语句

    国家级,世界级,最高级, 最佳,最大,第一, 唯一,首个,首选, 最好,最大,精确, 顶级,最高,最低, 最,最具,最便宜, 最新,最先进,最大程度, 最新技术,最先进科学,国家级产品, 填补国内空白 ...

  7. ThinkPHP 3.2.3 视图模型的使用

    ThinkPHP 3.2.3 试图模型的手册地址是:http://www.kancloud.cn/manual/thinkphp/1781 实例 需求:在博客列表页读取博客的(id.标题.摘要.发布时 ...

  8. MySQL 启动时禁用了 InnoDB 引擎的解决方法

    今天在从本地数据库复制表数据到虚拟机 CentOS 6.6 上的数据库时,得到提示: Unknown table engine 'InnoDB' 于是在服务器 MySQL 中查看了引擎: mysql& ...

  9. js判断字符是否包含字母汉字

    <script type="text/javascript"> function check(str) { if (escape(str).indexOf(" ...

  10. Mac OS X 背后的故事

    Mac OS X 背后的故事 作者: 王越  来源: <程序员>  发布时间: 2013-01-22 10:55  阅读: 25840 次  推荐: 49   原文链接   [收藏]   ...