Xcode 13更新高度UITableViewCell



告诉我如何在xcode 13中修复这种行为,更新单元格高度不起作用。在xcode 12.5.1工作良好https://www.icloud.com/iclouddrive/0Wq4Ml4Zl_0Hk4XcQxrQ3FIwg TableView

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if isHideCell && indexPath.row == 1 {
return 0
} else {
return tableView.rowHeight
}
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard indexPath.row == 0 else { return }
isHideCell = !isHideCell
tableView.performBatchUpdates(nil)
tableView.deselectRow(at: indexPath, animated: true)
}

这不是Xcode 13的问题iOS 15存在问题

显然(基于快速测试),heightForRowAt将零高度行视为"不可见行";所以是而不是如果你将该行的高度设置为0,则调用该行。

您可以尝试通过将行高设置为0.01来解决这个问题:

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if isHideCell && indexPath.row == 1 {
return 0.01
}
return tableView.rowHeight
}

最新更新