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

时间: 2024-08-24 10:06:55

UITableView 协议中常用的方法的相关文章

C语言中常用计时方法总结

转自:http://blog.csdn.net/fz_ywj/article/details/8109368 C语言中常用计时方法总结 1. time() 头文件:time.h 函数原型:time_t time(time_t * timer) 功能:返回以格林尼治时间(GMT)为标准,从1970年1月1日00:00:00到现在的此时此刻所经过的秒数. 用time()函数结合其他函数(如:localtime.gmtime.asctime.ctime)可以获得当前系统时间或是标准时间. 用difft

String对象中常用的方法

String对象中常用的方法 1.charCodeAt方法返回一个整数,代表指定位置字符的Unicode编码.strObj.charCodeAt(index)说明:index将被处理字符的从零开始计数的编号.有效值为0到字符串长度减1的数字.如果指定位置没有字符,将返回NaN.例如:      var  str = "ABC";      str.charCodeAt(0);结果:652.fromCharCode方法从一些Unicode字符串中返回一个字符串.String.fromCh

tomcat实现http协议中的请求方法

Tomcat是实现了http协议的web服务器. HttpServlet是整个J2EE体系的核心类.来自客户端的全部请求均有该类进行处理和转发.它由Tomcat根据web.xml中的servlet配置标记进行装载和管理. 以下是servlet继承结构. javax.servlet.httpClass HttpServlet java.lang.Object   javax.servlet.GenericServlet       javax.servlet.http.HttpServlet Al

Http协议中常用字段总结(不定时完善中)

1.Http协议概述 关于Http协议的发展,各种资料有很多,在此不再赘述,不明白的小伙伴儿可以去搜一下,Http报文分为请求报文和相应报文,由于Http是面向文本的,因此在报文中的每一个字段都是一些ASCII码,下图是摘自谢希仁第五版<计算机网络>的图片,本文按照这两种分类对报文头的字段进行一下汇总说明. 资料都是从给位大神那里获取到的,我只是负责汇总而已~ 2.Http请求报文 如上图(a)中为请求报文格式,分为请求行.首部行和实体主体(本文对实体主体不做说明,下同): 2.1 请求行 请

测试开发面试准备之HTTP协议-Http常用请求方法

那么HTTP请求报文和响应报文会是什么格式呢? 起始行:如 GET / HTTP/1.0 (请求的方法  请求的URL 请求所使用的协议) 头部信息:User-Agent  Host等成对出现的值 主体 不管是请求报文还是响应报文都会遵循以上的格式. 那么起始行中的请求方法有哪些种呢? GET: 完整请求一个资源 (常用) HEAD: 仅请求响应首部 POST:提交表单  (常用) PUT: (webdav) 上传文件(但是浏览器不支持该方法) DELETE:(webdav) 删除 OPTION

【java】开发中常用字符串方法

java字符串的功能可以说非常强大, 它的每一种方法也都很有用. java字符串中常用的有两种字符串类, 分别是String类和StringBuffer类. Sting类 String类的对象是不可变的. 创建String String() String(String str) String(char value[]) //用字符数组生成一个串对象 String(char value[], int offset, int count) //用字符数组value的offset位开始的count个字

总结 String、StringBuffer与StringBuilder类中常用的方法

一.String类的常用方法 1 1.获取: 2 1)获取字符串str长度 3 int i = str.length(); 4 2)根据位置(index)获取字符 5 char c = str.charAt(index); 6 3)获取字符在字符串中的位置 7 int i =str.indexOf(char ch); //获取的是第一次出现的位置 8 int i =str.indexOf(char ch ,int index); //从位置index后获取ch出现的第一次的位置 9 int i

Linq中常用的方法

这几天闲着也是闲着,就仔细的研究了一下Linq的语法,还有他的一些扩展方法的使用. 下面是一些常用的扩展方法. Aggregate 自定义的聚合计算 All 检测序列中所有元素是否都满足指定的条件 Any 检测序列中是否存在满足指定条件的元素 Average 计算序列中元素的平均值 Cast 将序列中元素的类型转换成指定的类型(由TResult参数指定) Contact 将一个序列中的元素全部追加到另一个序列中,并构成一个新的序列. Contains 检测序列中是否存在指定的元素. Count

收集JavaScript中常用的方法函数

本文中,收集了一些比较常用的Javascript函数,希望对学习JS的朋友们有所帮助. 1. 字符串长度截取 function cutstr(str, len) { var temp, icount = 0, patrn = /[^\x00-\xff]/, strre = ""; for (var i = 0; i < str.length; i++) { if (icount < len - 1) { temp = str.substr(i, 1); if (patrn.