
自定义UITableView各种函数
发布日期:2021-05-09 04:03:54
浏览次数:11
分类:博客文章
本文共 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
发表评论
最新留言
留言是一种美德,欢迎回访!
[***.207.175.100]2025年04月05日 17时07分52秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
【设计模式 - 结构型模式】1. 适配器模式
2019-03-06
C++9018:2333/2235——柠檬汽水(Lemonade Line)
2019-03-06
力扣 - 430. 扁平化多级双向链表
2019-03-06
力扣 - 232. 用栈实现队列.md
2019-03-06
过滤器和监听器总结
2019-03-06
MinIO分布式集群的扩展方案及实现
2019-03-06
《深度探索C++对象模型》第二章 | 构造函数语意学
2019-03-06
C++高精度模板
2019-03-06
洛谷 P1433 吃奶酪 状压DP
2019-03-06
错题重错之WYT的刷子 单调队列
2019-03-06
洛谷 P2403 [SDOI2010]所驼门王的宝藏 题解
2019-03-06
7.14 - 8.21 集训总结
2019-03-06
关于结构体的初始化
2019-03-06
CF600E Lomsat gelral 树上启发式合并
2019-03-06
洛谷 P6851 【onu】贪心
2019-03-06
联赛模拟测试20 B. Walk (建图)
2019-03-06
联赛模拟测试22 D. 简单计算
2019-03-06
联赛模拟测试23 D. 真相 思维题
2019-03-06
莫队学习笔记
2019-03-06
牛顿迭代学习笔记
2019-03-06