一、 设置title

在需要显示该返回键的前一个Controller中设置

   1:   navigationItem.backBarButtonItem = UIBarButtonItem(title: "注销", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

二、添加返回时执行Action:

你可以尝试一下在上一行代码中的target和action处填入事件监听的处理方法,但是不会起作用的。

backBarButtonItem的描述

Discussion

When this navigation item is immediately below the top item in the stack, the navigation controller derives the back button for the navigation bar from this navigation item. When this property is nil, the navigation item uses the value in its title property to create an appropriate back button. If you want to specify a custom image or title for the back button, you can assign a custom bar button item (with your custom title or image) to this property instead. When configuring your bar button item, do not assign a custom view to it; the navigation item ignores custom views in the back bar button anyway.

说明了backBarButtonItem只能自定义image和title,不能重写target or action,系统会忽略其他的相关设置项。

如果硬是需要重写action做一些其他的工作,则需要自定义一个leftBarButtonItem,因为系统定义leftBarButtonItem的显示优先级比backBarButtonItem优先级高,当存在leftBarButtonItem时,自动忽略backBarButtonItem,达到重写backBarButtonItem的目的。

 

 

注意点

一般我们取导航控制器上的Item这样取:

navigationItem.backbarItem

如果这样表示套了两层的导航栏的最外面那层的Item,一般情况下没有这样的嵌套。

navigationController.navigationItem.backBarButtonItem

 

 

Ref:

http://blog.csdn.net/dreamno23/article/details/21085783

http://www.cnblogs.com/ihojin/p/change-backbarbuttonitem-text.html

iOS中设置backBarButtonItem的title和action的更多相关文章

  1. iOS开发小技巧--iOS中设置applicationIconBadgeNumber遇到的问题

    iOS中设置applicationIconBadgeNumber 在iOS7中直接设置applicationIconBadgeNumber没有问题,但是在iOS8之后设置applicationIcon ...

  2. 【转】iOS中设置导航栏标题的字体颜色和大小

    原文网址:http://www.360doc.com/content/15/0417/11/20919452_463847404.shtml iOS中设置导航栏标题的字体颜色和大小,有需要的朋友可以参 ...

  3. iOS中设置导航栏标题的字体颜色和大小

    iOS中设置导航栏标题的字体颜色和大小,有需要的朋友可以参考下. 在平时开发项目的时候,难免会遇到修改导航栏字体大小和颜色的需求,一般使用自定义视图的方法,其实还存在一种方法. 方法一:(自定义视图的 ...

  4. iOS: 动态更改 backBarButtonItem 的 title

    先来看一下 UIBarItem 的 title 的描述 The title displayed on the item. You should set this property before add ...

  5. IOS中设置状态栏的状态

    IOS上 关于状态栏的相关设置(UIStatusBar) 知识普及 ios上状态栏 就是指的最上面的20像素高的部分 状态栏分前后两部分,要分清这两个概念,后面会用到: 前景部分:就是指的显示电池.时 ...

  6. IOS中设置cell的背景view和选中时的背景view 、设置cell最右边的指示器(比如箭头\文本标签)

    一.Cell的设置 1.设置cell的背景view和选中时的背景view UIImageView *bg = [[UIImageView alloc] init]; bg.image = [UIIma ...

  7. ios中设置input为readonly后,解决弹起软键盘的问题

    可以在input中添加unselectable="on" onfocus="this.blur()",可以解决软键盘弹起问题 <input type=&q ...

  8. ios中设置UIButton圆角,添加边框

    //例如: UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(50, ...

  9. 解决iOS中 tabBarItem设置图片(image+title切图在一起)时造成的图片向上偏移

    解决iOS中 tabBarItem设置图片(image+title切图在一起)时造成的图片向上偏移 解决办法1:设置tabBarItem的imageInsets属性 代码示例: childContro ...

随机推荐

  1. es6+最佳入门实践(14)

    14.模版字符串 模版字符串(template string)是增强版的字符串,定义一个模版字符串需要用到反引号 let s = `这是一个模版字符串` console.log(s) 14.1.模版字 ...

  2. java.lang.NumberFormatException: For input string: "26.0"

    数据类型转化的时候的错误: 程序中要转的字符串不是一个数字,所以在format成数字的时候就出错了.    字符串不符合数字预定格式.

  3. Restful 接口权限控制

    前言 有人说,每个人都是平等的: 也有人说,人生来就是不平等的: 在人类社会中,并没有绝对的公平, 一件事,并不是所有人都能去做: 一样物,并不是所有人都能够拥有. 每个人都有自己的角色,每种角色都有 ...

  4. java web标签

    一:国庆结束了,回来上班,结果老大说过两天才出差,所以这两天就用来补自己不太懂的知识或者以前没有熟悉的知识,jsp的标签就是,因为在项目中自己封装了一些标签,但是我自己只是会用,真正的原理性的东西我还 ...

  5. SDK登录cognos

    通过SDK登录cognos 一种是拼xml,如这里的实现https://github.com/cosysoft/cognos-tools/blob/master/src/com/ibm/cognos/ ...

  6. loj6029 「雅礼集训 2017 Day1」市场

    传送门:https://loj.ac/problem/6029 [题解] 考虑如果有一些近似连续的段 比如 2 2 2 3 3 3,考虑在除3意义下,变成0 0 0 1 1 1,相当于整体-2 又:区 ...

  7. Java易错知识点(2) - 在读取Cookie时除了Key,Value是得不到其他信息的

    全文总结: 在读取Cookie,然后操作时,除了getName(),getValue()外,不要妄图得到其他信息,如下方法不会得到值的: cookie.getMaxAge(); cookie.getD ...

  8. mysql索引作用的简单理解

    转自:http://blog.csdn.net/pengsidong/article/details/62104703,有添加 索引好比书的目录,好比新华字典的拼音.偏旁部首查字,可以帮助人快速查找到 ...

  9. Centos下yum update与yum upgrade的区别

    转载来源于:http://www.cnblogs.com/EasonJim/p/9026357.html 说明:生产环境对软件版本和内核版本要求非常精确,别没事有事随便的进行yum update操作! ...

  10. Redis-4.0.8 readme.md

    This README is just a fast *quick start* document. You can find more detailed documentation at [redi ...