您需要使用 tableview 委托方法设置自定义单元格的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0) {
return 150.0;
}else if (indexPath.row == 1){
return 300.0;
}
return 0.0;
}
Run Code Online (Sandbox Code Playgroud)
以及您需要在数据源方法中将您的自定义单元格 cliptobound 属性设置为 yes
- (CGFloat)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
customcell *cell = (customcell *)[tableView dequeResusableCellWithIdentifier:@"newcell" forIndexPath:indexPath];
cell.cliptobound = YES;
return cell;
}
Run Code Online (Sandbox Code Playgroud)