When did set change heightForRowAt UITableView animation is broken cell is a jumped. If selected last row and scroll on top and after a tap for collapsed row the table jumps to up. The animation is broke.
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
tableView.estimatedRowHeight = 300
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return conditionData[indexPath.section].conditions?[indexPath.row].selected ?? false ? 300 : 76
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
conditionData[indexPath.section].conditions?[indexPath.row].selected = true
tableView.beginUpdates()
let cell = tableView.cellForRow(at: indexPath) as? ConditionsCell
cell?.setSelected(true, animated: true)
tableView.endUpdates()
}
func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
conditionData[indexPath.section].conditions?[indexPath.row].selected = false
tableView.beginUpdates()
let cell = tableView.cellForRow(at: indexPath) as? ConditionsCell
cell?.setSelected(false, animated: true)
tableView.endUpdates()
}
