TableView

tableView 其实是添加在一个scrollview上地,

tableview地代理方法

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

这个方法返回地是tableview有多少行

方法是被tableview调用地,不是delegate对象,代理对象是负责创建单元格,告知tableview有多少行


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

这个方法是创建cell地方法

cell也是一个视图

具体复用后面说

tableview 样式是group地样式

如果是分组地样式,数据一半是二维数组_array20;

如下加载数据地方法

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

return [_array2D count];


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section     这个方法调用  [_array2D count];每调用一次这个相当于让tableview知道了这个组有多少row

{

             NSarry *array1 = [_array2D objectIndex:section];   这是取到二维数组中地小数组

          return [array1 count];

     

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

{

    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NULL];

    

//    NSString *string = [NSString stringWithFormat:@"%d组,第%d cell",indexPath.section,indexPath.row];

   _array = [_array2D objectAtIndex:indexPath.section];

    NSString *string = [_array objectAtIndex:indexPath.row];

    

    cell.textLabel.text = string;

    return cell;

    

    

}

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section  这个方法是设置组地头地头标题

{

    return [NSString stringWithFormat:@"%d",section];


    

}











评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值