转自:http://blog.sina.com.cn/s/blog_7e3132ca0100wyls.html

在XCode对应头文件中修改该类所继承的父类:

在对应的.m文件中添加如下代码:

这样就在view上添加了一个tableView,但其样式是默认的,其中的内容也是空白的,而且此时是无法运行的,因为在头文件中添加了UITableViewDataSource和UITableViewDelegate两个类,所以必须设置一些自定义tableView样式的方法,下面列举了一些相关的方法:

设置Cell高度:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 设置SectionHeader高度:
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 设置SectionFooter高度:
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section 设置Section数目:
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 设置SectionHeader内容:
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ 设置各个Section中的Cell个数:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 设置Cell内容:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 设置Cell行缩进量:
-(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath 设置Cell被选中响应前动作(例如:可用以判断选中的Cell,来阻止其响应)
-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath 设置Cell选中触发响应:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

自定义UITableView各种函数的更多相关文章

  1. 我的MYSQL学习心得(十) 自定义存储过程和函数

    我的MYSQL学习心得(十) 自定义存储过程和函数 我的MYSQL学习心得(一) 简单语法 我的MYSQL学习心得(二) 数据类型宽度 我的MYSQL学习心得(三) 查看字段长度 我的MYSQL学习心 ...

  2. (Ios 实战) 自定义UITableView

    自定义UITableView 分成两个部分 1 自定义UITableViewCell 继承UITableViewCell,同时提供接口,根据当前的数据,现实View 2  在UITableView中实 ...

  3. PHP 错误与异常 笔记与总结(8)自定义错误处理函数 set_error_handler()

    通过 Set_error_handler() 函数设置用户自定义的错误处理函数. 步骤: ① 创建错误处理函数 ② 设置不同级别调用函数 ③ Set_error_handler() 函数制定接管错误处 ...

  4. 在String()构造器不存在的情况下自定义一个MyString()函数,实现如下内建String()方法和属性:

    在String()构造器不存在的情况下自定义一个MyString()函数,实现如下内建String()方法和属性: var s = new MyString("hello"); s ...

  5. Qt自定义sleep延时函数(巧妙的使用时间差,但这样似乎CPU满格,而不是沉睡)

    Qt不像VC++的win32/MFC编程那样,提供了现成的sleep函数可供调用.Qt把sleep函数封装在QThread类中.子线程可以调用sleep函数.但是如果用户想在主线程实现延时功能,该怎么 ...

  6. C程序中引用自定义的C函数模块

    原文:C程序中引用自定义的C函数模块 我们知道,刚开始接触C语言编程,一般都是在一个.c或者.cpp(以下只说.c)的文件中编写代码,其中一定会有一个入口函数, 也就是main()函数,你可以将程序代 ...

  7. 自定义一个EL函数

    自定义一个EL函数 一般就是一下几个步骤,顺便提供一个工作常用的 案例: 1.编写一个java类,并编写一个静态方法(必需是静态方法),如下所示: public class DateTag { pri ...

  8. 自定义JS Map 函数

    // 自定义JS Map 函数 function Map() { var map = function (key, value) {//键值对 this.key = key; this.value = ...

  9. GRDB自定义的纯函数

    GRDB自定义的纯函数   在GRDB中,用户可以自定义SQlite函数.这样,在SQL语句中,可以直接调用这些函数.但是在定义的时候,用户需要指定函数的pure属性,表示该函数是否为纯函数.纯函数是 ...

随机推荐

  1. Linq 知识回顾

    开篇语 在说LINQ之前必须先说说几个重要的C#语言特性 与LINQ有关的语言特性 隐式类型 (1)源起 在隐式类型出现之前, 我们在声明一个变量的时候, 总是要为一个变量指定他的类型 甚至在fore ...

  2. OpenCASCADE Interpolation - Lagrange

    OpenCASCADE Interpolation - Lagrange eryar@163.com Abstract. Power basis polynomial is the most simp ...

  3. Pipedata3d - Welding Neck Flange

    Pipedata3d - Welding Neck Flange eryar@163.com Abstract. Pipedata3d show piping component data in ta ...

  4. NPM使用前设置和升级

    升级版本npm3和切换模块数据源为taobao,大大提高下载速度. 步骤一:升级npm3默认npm为2.x推荐使用npm3. npm i -g npm@3 步骤二:修改npm数据源为taobao(默认 ...

  5. multipart数据结构

    --[boundary]\r\n [headers]\r\n \r\n [content]\r\n --[boundary]\r\n [headers]\r\n \r\n [content]\r\n ...

  6. geotrellis使用(十五)使用Bokeh进行栅格数据可视化统计

    Geotrellis系列文章链接地址http://www.cnblogs.com/shoufengwei/p/5619419.html 目录 前言 实现方案 总结 一.前言        之前有篇文章 ...

  7. HBase 数据模型(Data Model)

    HBase Data Model--HBase 数据模型(翻译) 在HBase中,数据是存储在有行有列的表格中.这是与关系型数据库重复的术语,并不是有用的类比.相反,HBase可以被认为是一个多维度的 ...

  8. Using Headless Mode in the Java SE Platform--转

    原文地址: By Artem Ananiev and Alla Redko, June 2006     Articles Index This article explains how to use ...

  9. EF中的实体类型【Types of Entity in Entity】(EF基础系列篇8)

    We created EDM for existing database in the previous section. As you have learned in the previous se ...

  10. asp.net获取客户端浏览器及主机信息

    在线预览效果:http://tool.hovertree.com/info/client/ 其中aspx页面的控件代码: <asp:ListBox runat="server" ...