iphone学习笔记--UITableView的基本方法

一. 表视图的委托、源以及类绑定

 

1.设置表视图分区(组)的方法

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
       //一组
        return 1;
}
2.设置表行数的方法
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
      //两行
      return 2;
}
3.初始化行单元的方法(一般绑定数据源都写这个方法里面)
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
     //声明标识
    static NSString *TableViewCellIndentifier = @"TableViewCellIndentifier ";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIndentifier:TableViewCellIndentifier];
    if(cell == nil){
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reusIndentifier:TableViewCellIndentifier] autorelease];
    }
    //赋值操作 
 

    return cell;      
}
4.当选中这行触发的事件
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

 }
5.当按下这行的详细箭头所触发的事件(一般会调用一个新的view)
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{

}
6.确定表行编辑类型的方法
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
    return UITableViewCellEditingStyleNone;表示移动类型
    return UITableViewCellEditingStyleDelete;表示删除类型
    return UITableViewCellEditingStyleInsert;表示插入类型
    //该方法只是定义类型 具体的实行要在具体方法中定义

}
7.移动操作方法
-(BOOL)table:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *) indexPaht{
    return YES;
}
8.删除、插入方法的实现
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle) editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{

 }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值