//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
网友评论