美文网首页
UI基础篇-UITableView

UI基础篇-UITableView

作者: nickNameDC | 来源:发表于2016-05-03 14:58 被阅读0次

    1.常用属性和方法

    tableHeaderView 头视图
    tableFooterView 尾视图
    separatorStyle 分割线
    editing 设置是否可编辑
    

    2代理方法

    //设置行高
    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    //选中哪一行
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:
    (NSIndexPath *)indexPath
    //设置是否可以编辑代理
    - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
    //返回编辑类型
    - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
    //定制删除按钮上的文字代理
    - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath: (NSIndexPath *)indexPath
    //删除表中一行代理
    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
    //删除后需要刷新数据源的方法
    - (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
    //设置是否可移动代理
    -(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
    //移动cell之后调 的代理
    - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
    //移动之后需要刷新数据源的方法
    - (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath
    //插入一行
    - (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
    

    3.UITableViewCell
    常用属性和方法

    设置选择样式
    @property (nonatomic) UITableViewCellSelectionStyle selectionStyle
    设置右边附件视图类型
    @property (nonatomic) UITableViewCellAccessoryType accessoryType
    '自定义创建cell'
    1.在控制器注册
    [self.tableView registerClass:[CustomCell class] forCellReuseIdentifier:@"cellID"];
    UINib *nib = [UINib nibWithNibName:@"MyCell" bundle:nil];
    [self.tableView registerNib:nib
         forCellReuseIdentifier:@"MyCell"];//xib方式
    2.在创建cell的方法中复用
    self = [tableView dequeueReusableCellWithIdentifier:@"MyCell"];
    

    相关文章

      网友评论

          本文标题:UI基础篇-UITableView

          本文链接:https://www.haomeiwen.com/subject/oltrrttx.html