tableView的使用方法详解
来源:互联网 发布:mac怎么更新显卡驱动 编辑:程序博客网 时间:2024/06/06 04:43
1 tableView的类型
1.1 UITableViewStylePlain 没有区头 不显区头 向上滑动区头不会移动到屏幕外面
’ 1.2 UITableViewStyleGrouped 有区头 表滑动,区头会移动
2 cell accessory cell的配件
//cell配件(accessory)
// 0 none 什么也没有
// 1 DisclosureIndicator 多了一个指向右侧的按钮
// 2 DetailButton 详细信息按钮
// 3 Checkmark 对勾
// 4 DetailDisclosureButton 详细信息按钮 + 指向右侧的箭头
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
还可以在设置huadong
3 设置cell 选中状态
//设置选择类型 默认为灰底
cell.selectionStyle = UITableViewCellSelectionStyleDefault;
4 NSCopying 协议 作用是只有实现此方法的类就可以调用copy方法
系统的某些类是默认实现NSCopying协议,诸如NSSting,NSArray,NSDictionary等;
所以 之前的People的类的对象默认是不能调用copy方法,因为People没有实现NSCopying协议中的copyWithZone方法.
临时字符串的引用计数是 -1 NSString *str = @"laosun";
通过创建字符串的对象的方式 引用计数为1 可以进行拷贝 引用计数加 1 效果等同于retain
NSString *str1 = [NSString stringWithFormat:@"laosun"];
4.1 浅拷贝 copy
retain拷贝的时指针,对象只有一个,结果使得对象的引用计数 + 1
4.2 深拷贝 真正意义上的拷贝,只是要产生两个对象,而且每个对象的引用计数是1
5 // 此属性就可以代替 设置区头高度的 协议方法
_tableView.sectionHeaderHeight = 50;
6 创建tableView所必须的三个方法
6.1 //在tableView上有几个区域
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
6.2 //每个区域有多上行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
6.3 每一行的cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
7 相关协议
7.1 区头需要多个控件 则可以先创建一个View,然后再view上添加控件,view和相关控件在如下的方法中创建
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
7.2 设置cell的编辑风格
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath;
风格类型
7.2.1 UITableViewCellEditingStyleDelete 删除
7.2.2 UITableViewCellEditingStyleInsert 插入
7.2.3 UITableViewCellEditingStyleNone 默认
7.3 cell是否可以移动 返回的时一个BOOL值
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
7.3.1 用来移动的三杠
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
移动逻辑: 取>删>添加
7.4 完成编辑
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;
删除和插入所做的操作写在这里 删除逻辑:删除对象 > 删除行
8 展开闭合逻辑:
通过一个bool值判断(_falg[3]),如果是yes则返回相应数组的count,否则返回0 (在和行相关的方法中),刷新相应的行的数据
9 表的编辑 增 ,删 ,移
1.1 UITableViewStylePlain 没有区头 不显区头 向上滑动区头不会移动到屏幕外面
’ 1.2 UITableViewStyleGrouped 有区头 表滑动,区头会移动
2 cell accessory cell的配件
//cell配件(accessory)
// 0 none 什么也没有
// 1 DisclosureIndicator 多了一个指向右侧的按钮
// 2 DetailButton 详细信息按钮
// 3 Checkmark 对勾
// 4 DetailDisclosureButton 详细信息按钮 + 指向右侧的箭头
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
还可以在设置huadong
3 设置cell 选中状态
//设置选择类型 默认为灰底
cell.selectionStyle = UITableViewCellSelectionStyleDefault;
4 NSCopying 协议 作用是只有实现此方法的类就可以调用copy方法
系统的某些类是默认实现NSCopying协议,诸如NSSting,NSArray,NSDictionary等;
所以 之前的People的类的对象默认是不能调用copy方法,因为People没有实现NSCopying协议中的copyWithZone方法.
临时字符串的引用计数是 -1 NSString *str = @"laosun";
通过创建字符串的对象的方式 引用计数为1 可以进行拷贝 引用计数加 1 效果等同于retain
NSString *str1 = [NSString stringWithFormat:@"laosun"];
4.1 浅拷贝 copy
retain拷贝的时指针,对象只有一个,结果使得对象的引用计数 + 1
4.2 深拷贝 真正意义上的拷贝,只是要产生两个对象,而且每个对象的引用计数是1
5 // 此属性就可以代替 设置区头高度的 协议方法
_tableView.sectionHeaderHeight = 50;
6 创建tableView所必须的三个方法
6.1 //在tableView上有几个区域
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
6.2 //每个区域有多上行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
6.3 每一行的cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
7 相关协议
7.1 区头需要多个控件 则可以先创建一个View,然后再view上添加控件,view和相关控件在如下的方法中创建
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
7.2 设置cell的编辑风格
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath;
风格类型
7.2.1 UITableViewCellEditingStyleDelete 删除
7.2.2 UITableViewCellEditingStyleInsert 插入
7.2.3 UITableViewCellEditingStyleNone 默认
7.3 cell是否可以移动 返回的时一个BOOL值
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
7.3.1 用来移动的三杠
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
移动逻辑: 取>删>添加
7.4 完成编辑
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;
删除和插入所做的操作写在这里 删除逻辑:删除对象 > 删除行
8 展开闭合逻辑:
通过一个bool值判断(_falg[3]),如果是yes则返回相应数组的count,否则返回0 (在和行相关的方法中),刷新相应的行的数据
9 表的编辑 增 ,删 ,移
0 0
- tableView的使用方法详解
- tableview的一些使用方法
- TableView 的方法详解
- 关于tableview的 [self.tableView registerClass: forCellReuseIdentifier:使用方法
- ios的tableView使用详解
- tableview 详解
- TableView详解
- tableView详解
- TableView详解
- TableView详解
- tableview 详解
- TableView详解
- tableView详解
- TableView详解
- tableView 详细使用方法
- repeater的使用方法详解
- TStringList 的使用方法详解
- JSplitPane的使用方法详解
- 搭建ftp
- C fopen,fseek,fprintf,feof,ftell,rewind
- poj 1273 Drainage Ditches
- Delphi 代码创建控件与事件动态绑定
- 翻译Orchard的文档 Alternates(候补)
- tableView的使用方法详解
- qt编译oracle插件驱动
- 升级Win10 Build 10525激活方面遇到的一些问题解答汇总
- iOS 项目的目录结构
- ICTCLAS分词关键技术
- 浅析常用的排序算法
- 自适应网页设计的方法(手机端良好的访问体验)
- 黑马程序员——011——JavaAPI③(集合框架(List之LinkedList)、(Set之HashSet)
- 文字上添加删除线