iOS中设置backBarButtonItem的title和action
一、 设置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的更多相关文章
- iOS开发小技巧--iOS中设置applicationIconBadgeNumber遇到的问题
iOS中设置applicationIconBadgeNumber 在iOS7中直接设置applicationIconBadgeNumber没有问题,但是在iOS8之后设置applicationIcon ...
- 【转】iOS中设置导航栏标题的字体颜色和大小
原文网址:http://www.360doc.com/content/15/0417/11/20919452_463847404.shtml iOS中设置导航栏标题的字体颜色和大小,有需要的朋友可以参 ...
- iOS中设置导航栏标题的字体颜色和大小
iOS中设置导航栏标题的字体颜色和大小,有需要的朋友可以参考下. 在平时开发项目的时候,难免会遇到修改导航栏字体大小和颜色的需求,一般使用自定义视图的方法,其实还存在一种方法. 方法一:(自定义视图的 ...
- iOS: 动态更改 backBarButtonItem 的 title
先来看一下 UIBarItem 的 title 的描述 The title displayed on the item. You should set this property before add ...
- IOS中设置状态栏的状态
IOS上 关于状态栏的相关设置(UIStatusBar) 知识普及 ios上状态栏 就是指的最上面的20像素高的部分 状态栏分前后两部分,要分清这两个概念,后面会用到: 前景部分:就是指的显示电池.时 ...
- IOS中设置cell的背景view和选中时的背景view 、设置cell最右边的指示器(比如箭头\文本标签)
一.Cell的设置 1.设置cell的背景view和选中时的背景view UIImageView *bg = [[UIImageView alloc] init]; bg.image = [UIIma ...
- ios中设置input为readonly后,解决弹起软键盘的问题
可以在input中添加unselectable="on" onfocus="this.blur()",可以解决软键盘弹起问题 <input type=&q ...
- ios中设置UIButton圆角,添加边框
//例如: UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(50, ...
- 解决iOS中 tabBarItem设置图片(image+title切图在一起)时造成的图片向上偏移
解决iOS中 tabBarItem设置图片(image+title切图在一起)时造成的图片向上偏移 解决办法1:设置tabBarItem的imageInsets属性 代码示例: childContro ...
随机推荐
- js 内置对象属性及方法
1.Date 属性(1): constructor 所建立对象的函数参考 prototype 能够为对象加入的属性和方法 方法(43): getDay() 返回一周 ...
- ubuntu12.04回归到经典的gnome界面
要想删除Unity恢复到经典Gnome桌面也很简单,几乎就是一条命令的事情--命令这种东西虽然不直观,但非常可靠和快捷,同时按住Ctrl+Alt+T三个键,调出系统终端,输入: sudoapt-get ...
- elementUi 组件--el-table
[需求]在element中,将表格中的数据进行处理,然后渲染出来.例如,将数据保留小数点后两位显示. [知识点]formatter:用来格式化内容 [分析]在element 的table中,实现的过程 ...
- 调整文本输入框placeholder的颜色等样式
input::-webkit-input-placeholder{ color: white !important;}input:-moz-placeholder{ color: whi ...
- rest service技术选型
MySql workbench下载 http://dev.mysql.com/downloads/workbench/ 最好的8个 Java RESTful 框架 http://colobu.com/ ...
- LCD实验学习笔记(四):系统时钟
一般CPU频率(FCLK)高于内存.网卡等设备频率(HCLK),而串口.USB.I2C等设备频率(PCLK)更低. 系统时钟: 系统时钟源为晶振,初始频率12MHz. 通过设置MPLLCON寄存器的M ...
- python3 正则表达式re模块
正则表达式的功能:字符串的模糊匹配查询import re元字符 . ---->匹配除换行符意外的任意字符 ^ ---->匹配行首位置 $ ---->匹配行尾位置 关于重复的元字符 * ...
- I2C和SPI总线对比【转】
转自:http://blog.csdn.net/skyflying2012/article/details/8237881/ 最近2周一直在调试IIC和SPI总线设备,这里记录一下2种总线,以备后忘. ...
- mvn常用的构建命令
mvn -v 查看maven版本 mvn compile 编译 mvn test 测试 mvn package 打包 mvn clean 删除target mvn install 安装jar包到本地仓 ...
- Java处理文件BOM头的方式推荐
背景: java普通的文件读取方式对于bom是无法正常识别的. 使用普通的InputStreamReader,如果采用的编码正确,那么可以获得正确的字符,但bom仍然附带在结果中,很容易导致数据处理出 ...