Когда установлено изменение высоты, для ForForowAt UITableView анимация не работает, ячейка перепрыгивается.Если выбрана последняя строка и прокрутка вверху, а после касания свернутой строки таблица переместится вверх.Анимация сломана.
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()
}