博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
tableView的使用方法详解
阅读量:4074 次
发布时间:2019-05-25

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

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    表的编辑  增 ,删 ,移

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

你可能感兴趣的文章
read humor_campus
查看>>
IBM WebSphere Commerce Analyzer
查看>>
Unix + OS IBM Aix FTP / wu-ftp / proftp
查看>>
my read work
查看>>
db db2 base / instance database tablespace container
查看>>
hd disk / disk raid / disk io / iops / iostat / iowait / iotop / iometer
查看>>
project ASP.NET
查看>>
db db2_monitorTool IBM Rational Performace Tester
查看>>
OS + Unix Aix telnet
查看>>
IBM Lotus
查看>>
Linux +Win LAMPP Tools XAMPP 1.7.3 / 5.6.3
查看>>
my read_university
查看>>
network manager
查看>>
OS + Linux Disk disk lvm / disk partition / disk mount / disk io
查看>>
RedHat + OS CPU、MEM、DISK
查看>>
net TCP/IP / TIME_WAIT / tcpip / iperf / cain
查看>>
webServer kzserver/1.0.0
查看>>
OS + Unix IBM Aix basic / topas / nmon / filemon / vmstat / iostat / sysstat/sar
查看>>
my ReadMap subway / metro / map / ditie / gaotie / traffic / jiaotong
查看>>
OS + Linux DNS Server Bind
查看>>