一、 设置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

最新文章

  1. webstorm对WebGL自动提示
  2. MySQL主从复制中常见的3个错误及填坑方案
  3. 创建两个对象的两种方法,一中\new,另外一种不new
  4. 建立 svn 服务端
  5. Action类为何要 extends ActionSupport
  6. .Net Core 项目中的包引用探索(使用VSCode)
  7. Python学习笔记——几种数据类型
  8. 《C语言深度剖析》学习笔记----C语言中的符号
  9. Knockout应用开发指南 第三章:绑定语法(1)
  10. Oracle Day07 PL/SQL基础
  11. Matlab R2013a: C++ MEX on Ubuntu 14.04 64-bit
  12. 【Java并发.4】对象的组合
  13. git最佳实践之feature和hotfix分支
  14. 安装php调试工具 Xdebug的步骤 火狐 phpstorm联调
  15. Node 开启
  16. re正则模块(二十五)
  17. Android截图命令screencap与视频录制命令screenrecord
  18. SharpZipLib 压缩ZIP导出
  19. Application Metrics With Spring Boot Actuator
  20. go语言之行--数组、切片、map

热门文章

  1. Install the AWS Command Line Interface on Linux
  2. centos网络配置之桥接模式
  3. BZOJ 2063: 我爸是李刚
  4. bzoj1036: [ZJOI2008]树的统计Count link-cut-tree版
  5. #error#学习方法,如何避免初始化错误
  6. linux内核分析笔记----中断和中断处理程序【转】
  7. docker常用命令,安装常用实例,一步式安装mysql
  8. 3.资源调度框架yarn
  9. PHPstorm创建注释模版
  10. 【 VSFTPD 】ftp 客户端问题