2019独角兽企业重金招聘Python工程师标准>>>

ios学习--TableView详细解释

分类: ios Object-C 2012-05-17 08:48  1714人阅读  评论(0)  收藏  举报

-、建立 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];
转自:http://no001.blog.51cto.com/1142339/637651

转载于:https://my.oschina.net/u/853999/blog/86511

ios学习--TableView详细解释相关推荐

  1. iOS开发--TableView详细解释

    -.建立 UITableView DataTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 420)]; [DataTa ...

  2. Nacos学习及详细解释配置与注册

    原作者:nacos 实战(史上最全) - 疯狂创客圈 - 博客园 一.若依的配置中心共享配置的shared-configs的配置方式: RuoYi-Cloud:

  3. UIApplication sharedApplication详细解释-IOS

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

  4. 运放输入偏置电流方向_连载 | 运放参数的详细解释和分析part2如何测量输入偏置电流Ib和输入失调电流Ios...

    点击上方蓝字   获取更多电子硬件知识 对第part1中的的概念作出声明:Ib-,Ib+为运放两输入端的偏置电流,也可以叫做偏置电流.而我们所说的运放输入偏置电流通常为两者的平均值,运放输入失调电流为 ...

  5. ios学习--iphone开发笔记和技巧总结(原址持续更新)

    ios学习--iphone开发笔记和技巧总结(原址持续更新) 分类: ios Object-C2012-04-18 10:16 2716人阅读 评论(1) 收藏 举报 uiviewiphonelist ...

  6. iOS学习笔记-自己动手写RESideMenu

    代码地址如下: http://www.demodashi.com/demo/11683.html 很多app都实现了类似RESideMenu的效果,RESideMenu是Github上面一个stars ...

  7. ios学习 准备列表

    2019独角兽企业重金招聘Python工程师标准>>> Skip to content This repository Pull requests Issues Gist Watch ...

  8. iOS -- 学习资料总结(转载)

    先著名转载地址:https://www.jianshu.com/p/c47c24ab1e76/ 关于iOS学习进阶的必读一些博客总结 经过一周的思考还是决定重组一下优秀的博客,首次整理这些博客比较乱, ...

  9. iOS学习 —— 数据加密

    iOS学习 -- 数据加密相关介绍 AES加密 aes(The Advanced Encryption Standard)是美国国家标准与技术研究所用于加密电子数据的规范.它被预期能成为人们公认的加密 ...

最新文章

  1. Spring ----Bean的生命周期
  2. learn python the hard way习题31~40总结以及列表的扩展知识
  3. 【Python-ML】抽取最优化分类的特征子空间的LDA方法
  4. 《循序渐进学Spark》一1.7 本章小结
  5. python批量下载b站_python 批量下载bilibili视频的gui程序
  6. 区块链的爆发仍为时尚早......
  7. python 螺旋数组_奇技淫巧 - Python绘制各种简单优美曲线
  8. python共轭梯度法_Numerical Analysis: 共轭梯度法(1)--基本原理
  9. java实现户籍管理系统_基于javaweb的户籍管理系统(含配套论文等资料)
  10. 网页/公众号音乐下载
  11. 手搓GPT系列之 - Logistic Regression模型,Softmax模型的损失函数与CrossEntropyLoss的关系
  12. 用CSS做的简单弹窗
  13. 菜鸟进阶黑客知识整合大全(2)
  14. 水源热泵机组变流量水系统节能优化探讨
  15. 虚拟现实技术——Cocos Creator 动画系统动作笔记
  16. oracle数据库关闭失败,Oracle突然关闭原因
  17. 网络安全电子数据取证如何学习?
  18. 排查链接是否失效_锅炉主保护系统隐患排查与治理
  19. QQ电脑管家电脑安全大师
  20. [附源码]Python计算机毕业设计超市销售管理系统Django(程序+LW)

热门文章

  1. arg是什么函数_怎么实现边听歌边搜图?线程初体验:常用函数
  2. python某行某列读取数据_使用scrpython从某行的第一列提取数据
  3. 高考计算机会考基础知识点,2017高考一定会考的46个知识点!
  4. 全局对象_C++全局变量初始化
  5. mysql+地图网格数据下载_echarts 中国各省市 echarts地图数据,含世界地图
  6. 复制出来的文本都是大写_好用又冷门的Word快捷键,据说80%的人都不知道!
  7. 关于华为鸿蒙的三个核心问题
  8. Android开发第二次课 布局方式
  9. python函数(一)
  10. WEB中的敏感文件泄露