(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. js中return,this,arguments,currentStyle和getComputedStyle小析

    一.return返回值:1.函数名+括号:fn()==>return 后面的值2.所有函数默认返回值:未定义3.return后面的任何代码都不会执行二.this:当前对象1.当某个对象后边加事件 ...

  2. 如何用bat批处理编译swf项目

    平时用FB等IDE编译多模块的游戏项目时,除了添加移除模块的操作很繁琐外,编译速度也非常之慢.而用bat来编译swf项目,速度非常快,稳定. 在此分享自己工作用的bat,每次运行会重新编译主模块Gam ...

  3. Unique Binary Search Trees

    Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...

  4. EF 关系规则(一对一、一对多、多对多...)

    转自: http://www.cnblogs.com/dudu/archive/2011/07/11/ef_one-to-one_one-to-many_many-to-many.html Entit ...

  5. 类 class

    <?php class Person{ //定义一个类 public $name; //定义属性 public $age; function say(){ //定义办法 echo "m ...

  6. IOS第二天多线程-04简化单例模式

    ******HMSingleton-ARC.h // .h文件 #define HMSingletonH(name) + (instancetype)shared##name; // .m文件 #de ...

  7. IOS第18天(8,核心动画转场动画)

    ***翻页效果 #import "HMViewController.h" @interface HMViewController () @property (weak, nonat ...

  8. 四个查找命令find,locate,whereis,which的区别

    find最强大,但是检索硬盘,比较慢: whereis只能查二进制文件.说明文档,源文件等: locate能查所有文件,但跟whereis一样都是查数据库里的内容,速度快,但有延时: which 只能 ...

  9. 【iCore3 双核心板_FPGA】例程五:Signal Tapll实验——逻辑分析仪

    实验指导书及代码包下载: http://pan.baidu.com/s/1bnNRfaB iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...

  10. Java与C++面向对象不同点

    首先面向对象的语言有哪些?JAVA.C++.C#等等.但是呢很多人认为C#和C++有关系,其实一点关系都是没有滴.C#是仿Java做的,很多人都说是假Java,因为C#和Java太像了比如C#也有st ...