告訴我如何在 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)
}
uj5u.com熱心網友回復:
也許您需要重新加載特定的單元格,它們將達到新的高度
tableView.reloadRows(at: [IndexPath], with: UITableView.RowAnimation)
uj5u.com熱心網友回復:
這不是Xcode 13的問題——而是iOS 15的問題
顯然(基于快速測驗),heightForRowAt將零高度行視為“不可見行”,因此如果您將其高度設定為零,則不會呼叫該行。
您可以嘗試通過將行高設定為來解決此問題0.01:
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if isHideCell && indexPath.row == 1 {
return 0.01
}
return tableView.rowHeight
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/330658.html
