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 协议中常用的方法的更多相关文章

  1. org.apache.commons.lang.StringUtils中常用的方法

    org.apache.commons.lang.StringUtils中常用的方法,这里主要列举String中没有,且比较有用的方法: 1. 检查字符串是否为空: static boolean isB ...

  2. String对象中常用的方法

    String对象中常用的方法   1.charCodeAt方法返回一个整数,代表指定位置字符的Unicode编码.strObj.charCodeAt(index)说明:index将被处理字符的从零开始 ...

  3. 项目中常用js方法整理common.js

    抽空把项目中常用js方法整理成了common.js,都是网上搜集而来的,大家一起分享吧. var h = {}; h.get = function (url, data, ok, error) { $ ...

  4. String:(字符串)中常用的方法

    package stringyiwen; //字符串中常用的方法public class StringTest03 { public static void main(String[] args) { ...

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

    转自:http://blog.csdn.net/fz_ywj/article/details/8109368 C语言中常用计时方法总结 1. time() 头文件:time.h 函数原型:time_t ...

  6. 大数据学习day13------第三阶段----scala01-----函数式编程。scala以及IDEA的安装,变量的定义,条件表达式,for循环(守卫模式,推导式,可变参数以及三种遍历方式),方法定义,数组以及集合(可变和非可变),数组中常用的方法

    具体见第三阶段scala-day01中的文档(scala编程基础---基础语法)  1. 函数式编程(https://www.cnblogs.com/wchukai/p/5651185.html): ...

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

    1.Http协议概述 关于Http协议的发展,各种资料有很多,在此不再赘述,不明白的小伙伴儿可以去搜一下,Http报文分为请求报文和相应报文,由于Http是面向文本的,因此在报文中的每一个字段都是一些 ...

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

    java字符串的功能可以说非常强大, 它的每一种方法也都很有用. java字符串中常用的有两种字符串类, 分别是String类和StringBuffer类. Sting类 String类的对象是不可变 ...

  9. day2 列表中常用的方法

    列表中有很多方法,下面来看看常用的方法,我们知道,字符串是以字符列表形式存储的.因此上面学习的字符串中的很多方法在列表中也有.     1.extend() extend()列表的扩展,把两个列表进行 ...

随机推荐

  1. DropDownList为啥总是获取第一项的值???

    小菜: DropDownList控件绑定的数据,在获取数据时总是获取到第一项,很是郁闷,怎么回事,于是就各种想,都没有找到问题的原因. 请看下面的代码 前台代码: <asp:DropDownLi ...

  2. 跳出for循环

    如下面,有两个循环,break只能退出一个for循环,不能直接跳过第二个for循环 for (Type type : types) { for (Type t : types2) { if (some ...

  3. HDU3496-Watch The Movie

    描述: New semester is coming, and DuoDuo has to go to school tomorrow. She decides to have fun tonight ...

  4. 【转】System.Data.OracleClient requires Oracle client software version 8.1.7 or greater

    安装完ASP.NET,Oracle9i客户端后,使用System.Data.OracleClient访问Oracle数据库如果出现这种错误:System.Data.OracleClient requi ...

  5. # void :;

    href="#"---->top 连续点击的时候会出bug javascri中的void是一个操作符,该操作符指定要计算一个表达式但是不返回值. javascript:voi ...

  6. 修改html很实用的insertAdjacentHTML方法

    添加HTML内容与文本内容以前用的是innerHTML与innerText方法, 最近发现还有insertAdjacentHTML和 insertAdjacentText方法, 这两个方法更灵活,可以 ...

  7. 基于Visual C++2013拆解世界五百强面试题--题11-查找数字出现次数

    在排序数组中,找出给定数字出现的次数比如{ 1, 2, 2, 2, 3}中2的出现次数是3次 我们可使用二分查找发,分别查找出2最先出现的位置和最后出现的位置相减即可. 下面是上代码: #includ ...

  8. hdoj 3018 Ant Trip(无向图欧拉路||一笔画+并查集)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3018 思路分析:题目可以看做一笔画问题,求最少画多少笔可以把所有的边画一次并且只画一次: 首先可以求出 ...

  9. [置顶] js综合应用:表格的四则运算

    在做调查问卷的过程中,遇到一个表格的统计问题,算是需要些js方面的综合知识,所以记录下来. 在上次完成了基本的求和的基础上,添加了基本的加减乘除四则运算. 基本需求简化后如下: 对应的htm了为: & ...

  10. ASP.NET页面传值的几种方式

    页面传值是学习asp.net初期都会面临的一个问题,总的来说有页面传值. 存储对象传值.ajax.类.model.表单等!下面欧柏泰克和大家一起来看看asp.net页面传值方式一般有哪些?常用的较简单 ...