-、建立 UITableView

DataTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 420)];
[DataTable setDelegate:self];
[DataTable setDataSource:self];
[self.view addSubview:DataTable];
[DataTable release];
二、UITableView各Method说明
//Section总数
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
return TitleData;
}
// Section Titles
//每个section显示的标题
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
return @"";
}
//指定有多少个分区(Section),默认为1
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 4;
}
//指定每个分区中有多少行,默认为1
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
}
//绘制Cell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
SimpleTableIdentifier];
if (cell == nil) {  
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier: SimpleTableIdentifier] autorelease];
}
cell.imageView.image=image;//未选cell时的图片
cell.imageView.highlightedImage=highlightImage;//选中cell后的图片
cell.text=//.....
return cell;
}
//行缩进
-(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath{
NSUInteger row = [indexPath row];
return row;
}
//改变行的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 40;
}
//定位
[TopicsTable setContentOffset:CGPointMake(0, promiseNum * 44 + Chapter * 20)];
//返回当前所选cell
NSIndexPath *ip = [NSIndexPath indexPathForRow:row inSection:section];
[TopicsTable selectRowAtIndexPath:ip animated:YES scrollPosition:UITableViewScrollPositionNone];
[tableView setSeparatorStyle:UITableViewCellSelectionStyleNone];
//选中Cell响应事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];//选中后的反显颜色即刻消失
}
//判断选中的行(阻止选中第一行)
-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger row = [indexPath row];
if (row == 0)
return nil;
return indexPath;
}
//划动cell是否出现del按钮
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
}
//编辑状态
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
[topicsTable setContentSize:CGSizeMake(0,controller.promiseNum * 44)];
//右侧添加一个索引表
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
}
//返回Section标题内容
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
}
//自定义划动时del按钮内容
- (NSString *)tableView:(UITableView *)tableView
titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
//跳到指的row or section
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:NO];
三、在UITableViewCell上建立UILable多行显示
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";   
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
UILabel *Datalabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 320, 44)];
[Datalabel setTag:100];
Datalabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[cell.contentView addSubview:Datalabel];
[Datalabel release];
UILabel *Datalabel = (UILabel *)[cell.contentView viewWithTag:100];
[Datalabel setFont:[UIFont boldSystemFontOfSize:18]];
Datalabel.text = [data.DataArray objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
//选中cell时的颜色
typedef enum {
UITableViewCellSelectionStyleNone,
UITableViewCellSelectionStyleBlue,
UITableViewCellSelectionStyleGray
} UITableViewCellSelectionStyle 
//cell右边按钮格式
typedef enum {
UITableViewCellAccessoryNone,                   // don't show any accessory view
UITableViewCellAccessoryDisclosureIndicator,    // regular chevron. doesn't track
UITableViewCellAccessoryDetailDisclosureButton, // blue button w/ chevron. tracks
UITableViewCellAccessoryCheckmark               // checkmark. doesn't track
} UITableViewCellAccessoryType
//是否加换行线
typedef enum {
UITableViewCellSeparatorStyleNone,
UITableViewCellSeparatorStyleSingleLine
} UITableViewCellSeparatorStyle//改变换行线颜色
tableView.separatorColor = [UIColor blueColor];

转载于:https://www.cnblogs.com/wanghuaijun/p/5469514.html

iOS开发--TableView详细解释相关推荐

  1. ios学习--TableView详细解释

    2019独角兽企业重金招聘Python工程师标准>>> ios学习--TableView详细解释 分类: ios Object-C 2012-05-17 08:48  1714人阅读 ...

  2. IOS开发-TableView表视图LV2

    在上一章节IOS开发-TableView表视图基础的学习后, 我觉得对于表视图的学习不应只局限于基础知识的学习,应用在实战中的话想要构建丰富的多元化视图界面我想还是必须深入地再学习下. 于是有了这个L ...

  3. IOS开发-TableView表视图基础

    表视图在IOS中的应用非常广泛,常用于展示显示数据列表. 在工具组中包含了Table View 和Table View Cell 每个表示图都是UITableView的一个实例,每个可见行都是UITa ...

  4. iOS开发 UILabel 详细介绍(属性+富文本)

    UILabel是iOS开发中最常用的一种标签了,在开发过程中,会用到各种个样的标签属性,一段文字中变颜色或者字体的样式等(这些都是富文本中的内容,用于美化文字),下面就让我来给大家做一个详细的UILa ...

  5. iOS开发 超详细Flutter开发环境搭建

    1 .安装Flutter 此文章针对针对移动开发者,关于Flutter环境搭建,仅供参考,也可参考官网<https://flutter.dve/> 1.1.下载Flutter SDK 进入 ...

  6. iOS开发tableview二级联动的细节实现中注意的细节总结

    首先说网络慢带来的数据显示问题 可以通过判断请求参数是否一致来刷新tableview. SJBCategaryModel * categaryModel = self.categarys[Catega ...

  7. FFmpeg在iOS开发中编译并使用

    FFmpeg简介 FFmpeg是一套可以用来记录.转换数字音频.视频,并能将其转化为流的开源计算机程序.读作:爱服爱服爱母派格.全称:Fast Forward Mpeg.直译:快速转换图像.FFmpe ...

  8. tableview,基本属性图片详细解释

    tableview 是在苹果客户端ios开发中使用的最多的东西之一啦.下面的图片详细介绍解释table的个个属性

  9. UIApplication sharedApplication详细解释-IOS

    UIApplication sharedApplication详细解释-IOS 分类: iOS开发2012-07-27 10:25 10287人阅读 评论(2) 收藏 举报 applicationui ...

最新文章

  1. 你训练的神经网络不对头的37个原因
  2. 2011年云计算发展趋势的五大预测
  3. 怎样使 Python 输出时不换行?
  4. Java 动态调试技术原理及实践
  5. 视图插入数据_SAP Fiori的ABAP编程模型-CDS视图创建
  6. 14.并发与异步 - 2.任务Task -《果壳中的c#》
  7. MSF(一):MSF基础
  8. 160 - 49 DueList.4
  9. SAP License:财务与会计的区别
  10. java不能对什么类型进行转换_@Value - 无法将类型'java.lang.String'的值转换为所需类型'java.lang.Integer'...
  11. java成绩管理系统代码_[转载]我写的Java学生成绩管理系统源代码
  12. dtcms 数据库结构分析
  13. Activiti工作流程详解
  14. word 任意页设置开始页码
  15. 《第一行代码——Android》封面诞生记
  16. 【NPDP产品经理】发散思维让你的思维视野更广阔
  17. Python爬虫实现网页自动刷票
  18. 挺全的HTML、CSS整理笔记
  19. 列出当前文件夹及其子文件夹下所有文件名称
  20. 2022新版彩虹易支付系统源码/运营版/支持当面付/通道轮询/16支付插件/免签约支付系统

热门文章

  1. python如何进阶提升_Python序列操作之进阶篇
  2. centos java服务器搭建_从零开始搭建CentOS 7服务器配置JavaWeb环境
  3. php psr4 控制器调用模型,控制器中调用模型添加数据
  4. linux如何给各节点时间同步,Linux 系统配置各个节点的时间一致性
  5. r型聚类分析怎么做_营销型网站怎么做?
  6. 华为云welink考试试题_华为内部开启WeLink项目,华为云是这样考虑的-通信/网络-与非网...
  7. 两组回归系数差异检验_【stata系列】——组间系数差异检验
  8. cgi硬盘安装增强版怎么用_天津专业补光灯怎么用-安装
  9. SparkSQL读取文件时,数据字段类型调整
  10. 微服务SpringCloud