静态cell和动态cell混用

来源:互联网 发布:轻松网络销售招聘 编辑:程序博客网 时间:2024/05/22 10:51

1.静态cell常用设置界面的,因为设置界面的的数据一般是死的,用静态cell比较方便搭建


2.现在实现在Storbord实现上面的cell是静态的cell,下面的cell是动态cell,实现两者混用的效果

    1>创建一个静态cell在tableView

主要是在

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

   //表示静态cell

    if (indexPath.section ==0) {

        return [supertableView:tableView cellForRowAtIndexPath:indexPath];

    }else{

   //表示动态cell 

        HTWarningViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:@"HTWarningViewCell"];

        return cell;


    } 

}

//表示cell中indexPath

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

{

    //表示动态cell在section  为  1  静态cell的section 0

    if (section ==1) {

         returnself.selectedUserList.count;

    }

    return [supertableView:tableView numberOfRowsInSection:section];

    

}

//表示cell的内容缩进

- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath{

    //表示动态cell在section  为  1  静态cell的section 0

if (indexPath.section ==1) {

            return 10;

    }

    return indexPath.row;

}




1 0