博客
关于我
自定义UITableView各种函数
阅读量:425 次
发布时间:2019-03-06

本文共 1324 字,大约阅读时间需要 4 分钟。

转自: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

 

转载地址:http://yhfyz.baihongyu.com/

你可能感兴趣的文章
Java之封装,继承,多态
查看>>
wait()与notify()
查看>>
使用js打印时去除页眉页脚
查看>>
Spring security OAuth2.0认证授权学习第二天(基础概念-RBAC)
查看>>
ORA-00904: "FILED_TYPE": 标识符无效
查看>>
数据仓库系列之维度建模
查看>>
java中DelayQueue的使用
查看>>
线程stop和Interrupt
查看>>
Android中定时执行任务的3种实现方法
查看>>
基于vue2.0实现仿百度前端分页效果(二)
查看>>
时间序列神器之争:Prophet VS LSTM
查看>>
SpringBoot中关于Mybatis使用的三个问题
查看>>
MapReduce实验
查看>>
java大数据最全课程学习笔记(1)--Hadoop简介和安装及伪分布式
查看>>
大部分程序员还不知道的 Servelt3 异步请求,原来这么简单?
查看>>
[apue] getopt 可能重排参数
查看>>
移动互联网恶意软件命名及分类
查看>>
PySide图形界面开发(一)
查看>>
Android如果有一个任意写入的漏洞,如何将写权限转成执行权限
查看>>
现代3D图形编程学习-基础简介(2) (译)
查看>>