UITableView 协议中常用的方法
UITableViewDataSource 协议中常用方法
1.设置右边 索引值
- ( NSArray *)sectionIndexTitlesForTableView:( UITableView *)tableView
2. 设置分组标识
- ( NSString *)tableView:( UITableView *)tableView titleForHeaderInSection:( NSInteger )section
3.
设置分组个数
- ( NSInteger )numberOfSectionsInTableView:( UITableView
*)tableView
4. 设置行数
- ( NSInteger )tableView:( UITableView *)tableView numberOfRowsInSection:( NSInteger )section
5. 创建
cell(使用重用机制,如下例)
- ( UITableViewCell *)tableView:( UITableView *)tableView cellForRowAtIndexPath:( NSIndexPath
*)indexPath
{
1.
创建重用标识符
static NSString *identifier = @"reuse”
;
2. 去重用队列中根据标识符取可重用的 cell
AddressBookCell *cell = [tableView dequeueReusableCellWithIdentifier :identifier];
3. 判断是否获取到可重用的 cell( 最后要空间释放 )
if (!cell) {
cell = [[[ AddressBookCell alloc ] initWithStyle : UITableViewCellStyleDefault reuseIdentifier :identifier] autorelease ];
}
return cell;
}
6. 设置 tableView 的每一行的编辑状态
(YES,可编辑)
- ( BOOL )tableView:( UITableView *)tableView canEditRowAtIndexPath:( NSIndexPath
*)indexPath
{
return YES
}
7.edit 按钮的点击事件 ( 当点击 edit 按钮时触发 )
- ( void )setEditing:( BOOL )editing animated:( BOOL )animated
8. 当提交编辑操作时触发
- ( void )tableView:( UITableView *)tableView commitEditingStyle:( UITableViewCellEditingStyle )editingStyle forRowAtIndexPath:( NSIndexPath *)indexPath
9. 设置 tableView 每一行是否允许移动(YES,可移动)
- ( BOOL )tableView:( UITableView *)tableView canMoveRowAtIndexPath:( NSIndexPath *)indexPath
{
return YES
}
10. 提交移动操作之后触发
- ( void )tableView:( UITableView *)tableView moveRowAtIndexPath:( NSIndexPath *)sourceIndexPath toIndexPath:( NSIndexPath *)destinationIndexPath
UITableViewDelegate协议中常用方法
1. 设置行高
- ( CGFloat )tableView:( UITableView *)tableView heightForRowAtIndexPath:( NSIndexPath *)indexPath
{
return 55;
}
2. 选中cell时触发
- ( void )tableView:( UITableView *)tableView didSelectRowAtIndexPath:( NSIndexPath *)indexPath
3. 设置 tableViewCell 的编辑样式 ( 插入 / 删除 )
- ( UITableViewCellEditingStyle )tableView:( UITableView *)tableView editingStyleForRowAtIndexPath:( NSIndexPath *)indexPath
4. 设置当点击编辑按钮时 上面显示的文字,如显示删除
- ( NSString *)tableView:( UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:( NSIndexPath *)indexPath NS_AVAILABLE_IOS ( 3 _0) { return @" 删除 " ; }
5. 设置 cell 移动的位置
- ( NSIndexPath *)tableView:( UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:( NSIndexPath *)sourceIndexPath toProposedIndexPath:( NSIndexPath *)proposedDestinationIndexPath
UITableView 协议中常用的方法的更多相关文章
- org.apache.commons.lang.StringUtils中常用的方法
org.apache.commons.lang.StringUtils中常用的方法,这里主要列举String中没有,且比较有用的方法: 1. 检查字符串是否为空: static boolean isB ...
- String对象中常用的方法
String对象中常用的方法 1.charCodeAt方法返回一个整数,代表指定位置字符的Unicode编码.strObj.charCodeAt(index)说明:index将被处理字符的从零开始 ...
- 项目中常用js方法整理common.js
抽空把项目中常用js方法整理成了common.js,都是网上搜集而来的,大家一起分享吧. var h = {}; h.get = function (url, data, ok, error) { $ ...
- String:(字符串)中常用的方法
package stringyiwen; //字符串中常用的方法public class StringTest03 { public static void main(String[] args) { ...
- C语言中常用计时方法总结
转自:http://blog.csdn.net/fz_ywj/article/details/8109368 C语言中常用计时方法总结 1. time() 头文件:time.h 函数原型:time_t ...
- 大数据学习day13------第三阶段----scala01-----函数式编程。scala以及IDEA的安装,变量的定义,条件表达式,for循环(守卫模式,推导式,可变参数以及三种遍历方式),方法定义,数组以及集合(可变和非可变),数组中常用的方法
具体见第三阶段scala-day01中的文档(scala编程基础---基础语法) 1. 函数式编程(https://www.cnblogs.com/wchukai/p/5651185.html): ...
- Http协议中常用字段总结(不定时完善中)
1.Http协议概述 关于Http协议的发展,各种资料有很多,在此不再赘述,不明白的小伙伴儿可以去搜一下,Http报文分为请求报文和相应报文,由于Http是面向文本的,因此在报文中的每一个字段都是一些 ...
- 【java】开发中常用字符串方法
java字符串的功能可以说非常强大, 它的每一种方法也都很有用. java字符串中常用的有两种字符串类, 分别是String类和StringBuffer类. Sting类 String类的对象是不可变 ...
- day2 列表中常用的方法
列表中有很多方法,下面来看看常用的方法,我们知道,字符串是以字符列表形式存储的.因此上面学习的字符串中的很多方法在列表中也有. 1.extend() extend()列表的扩展,把两个列表进行 ...
随机推荐
- zoj 1409 Communication System
/*如果要一个物体的多种属性,最好用结构体,不要用二维数组或者多维数组.用多维数组进行关键字排序很不稳定 */ /*给每个设备的所有价格排序,每个设备选取恰好比已知带宽大的价格(这个时候的比例最大) ...
- SQL数据库的应用一(Day 24)
哈哈,又到了新的一周.我们也开始学习新的知识了,从今天开始学习SQL数据库的一些知识.今天主要讲了一些数据库.表的创建管理,和一些约束的定义使用.(这里使用的是SQL语句)下面我就具体总结一下. 总结 ...
- 关于类似于自动填充搜索框的DEMO
接了个单子,客户要求左边输入时,右边自动到数据库查出对应内容,如果是单个INPUT还好,这个是动态增加INPUT,不过都是一样,关键是思路 这里遇到最郁闷的问题,就是我用的JQ1.9 以前用的JQ1. ...
- dedecms(织梦)自定义表单后台显示不全 自定义模型当中添加自定义字段后在后台添加内容后不显示解决方案
我们常用dedecms 自定义表单做留言功能.但是偶尔会遇到这样一个问题,就是 在前台提交表单后..后天显示不全.特别是中文字符 都不会显示, 比如下图: 这是因为 如果你织梦是gbk的话那就对了 ...
- bzoj 1295: [SCOI2009]最长距离
题目链接 1295: [SCOI2009]最长距离 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1165 Solved: 619[Submit][ ...
- bzoj 4373: 算术天才⑨与等差数列 hash
题目链接 题目大意: 给你n个数, 给两种操作, 一种给你l, r, k,问你[l, r]区间里的数排序后能否构成一个公差为k的等差数列. 另一种是将位置x的数变为y. 强制在线. 可以用hash来 ...
- 用PyRestful快速构建Tornado下REST APIs 的支持
一.安装PyRestful库 $ pip install pyrestful 二.使用案例 (一)books_service.py # -*- coding: utf-8 -*- import tor ...
- 13-C语言字符串函数库
目录: 一.C语言字符串函数库 二.用命令行输入参数 回到顶部 一.C语言字符串函数库 1 #include <string.h> 2 字符串复制 strcpy(参数1,参数2); 参数1 ...
- 隐藏nginx 版本号信息(转)
为了安全,想将http请求响应头里的nginx版本号信息隐藏掉: 1. nginx配置文件里增加 server_tokens off; server_tokens作用域是http server loc ...
- 推荐一些socket工具,TCP、UDP调试、抓包工具 推荐一些socket工具,TCP、UDP调试、抓包工具
还记得我在很久很久以前和大家推荐的Fiddler和Charles debugger么?他们都是HTTP的神器级调试工具,非常非常的好用.好工具能让你事半功倍,基本上,我是属于彻头彻尾的工具控. 假如有 ...