我有表视图单元格,其中包含堆栈视图。如果某些要求是正确的,堆栈视图应该只在一个单元格中。如果不是,那么应该减少细胞的高度。 当我使用.isHidden时,高度保持不变。但我想要从该单元格中删除堆栈视图。Swift 3表视图 - 从某些单元中删除堆栈视图
这里是我的代码:
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()
}
任何人都可以请告诉我如何做到这一点?
你可以尝试加上'self.tableView.beginUpdates()'和'self.tableView.endUpdates()'AF你删除堆栈视图并计算你的新高度? – ronatory