一个xib文件,出列不同的Cell

//tabview出列cell的代理方法,加载定制的三个xib出列三种cell。xib是数组
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    CUYearCardCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellID"];
    if (!cell) {
        if (indexPath.row == 0) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"CUYearCardCell" owner:nil options:nil] firstObject];
        } else if (indexPath.row == 1) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"CUYearCardCell" owner:nil options:nil] objectAtIndex:1];
        } else {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"CUYearCardCell" owner:nil options:nil] lastObject];
        }
        
    }
    
    return cell;
}
//cell的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        return 60;
    } else if (indexPath.row == 1) {
        return 60;
    } else {
        return 40;
    }
}

xib是个数组,按照左边的顺序进行排序。三个cell关联的都是一个类


B712F39E-3158-4384-831A-9EAD70F3640B.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容