[英]Set Table View Cell Height for Only One of Three Custom Cells
我有三个自定义TableViewCells
。 我需要在代码中为其设置heightForRowAtIndexPath
的三个单元之一,因为我无法在Storyboard中使用AutoLayout。
有没有一种方法可以为特定的自定义TableViewCell
设置heightForRowAtIndexPath
?
我的heightForRowAtIndexPath
:
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
id model = self.combinedModel[indexPath.row];
// Custom Table View Cell Two
if ([model isKindOfClass:[Data self]]) {
return 500;
}
// Custom Table View Cell One and Three
else {
// Not sure what to put here, but need to put something without setting a height
}
}
我在代码中执行以下操作:
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
id model = self.combinedModel[indexPath.row];
// Custom Table View Cell Two
if ([model isKindOfClass:[Data self]]) {
return 500;
} else {
return tableView.rowHeight; // return the default height
}
}
“在不设置高度的情况下放置东西”是没有意义的。 您需要给表格视图每个单元格的高度。 为其指定其他单元格使用的默认高度。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.