我有表格视图单元格,其中包含堆栈视图等。如果某些要求是真实的,堆栈视图应该只在一个单元格中。如果不是,则应降低单元格的高度。当我使用 .isHidden 时,高度保持不变。但我希望从该单元格中删除堆栈视图。
这是我的代码:
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "RumCell", for: indexPath) as! RumCell
let currentRum: Rum
currentRum = rumList[indexPath.row]
cell.rum = currentRum
if (cell.rum?.clubRatingJuicy == 0) && (cell.rum?.clubRatingGasy == 0) && (cell.rum?.clubRatingSpicy == 0) && (cell.rum?.clubRatingSweet == 0) {
cell.frame.size.height -= 76
}
return cell
}
如您所见,我尝试降低单元格高度,但这不起作用。我也试过这个,它不起作用:
if (cell.rum?.clubRatingJuicy == 0) && (cell.rum?.clubRatingGasy == 0) && (cell.rum?.clubRatingSpicy == 0) && (cell.rum?.clubRatingSweet == 0) {
cell.tastStack.removeFromSuperview()
}
谁能告诉我该怎么做?