1
我有奇怪的行爲。我的整個視圖控制器看起來像這樣(垂直排列):使用Autolay動畫動畫UIView UITableView的複選標記
- 的UILabel,
- 的UITableView,
- 的UIView(在需要時將在&滑出)。 [見PS]
我的UIView和底部佈局引導之間添加約束,我用這種方法制作動畫:
func toggleContinueButton(_ toggleOn: Bool) {
if toggleOn {
self.buttonViewConstraint.constant = 0
} else {
self.buttonViewConstraint.constant = -80
}
UIView.animate(withDuration: 0.5) {
self.view.layoutIfNeeded()
}
}
出於某種奇怪的原因,這個螺絲對號,也就是現在的「飛」從屏幕左邊緣的外側,右側移動到選定單元格右側的正確位置和預期位置。下面我有選擇/取消選擇的簡單代碼:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.cellForRow(at: indexPath)!.accessoryType = .checkmark
self.updateContinueButtonState()
}
func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
tableView.cellForRow(at: indexPath)!.accessoryType = .none
self.updateContinueButtonState()
}
有沒有人遇到過這樣的怪誕?
p.s.嘗試了兩個版本:第一,滑動UIView是在&徘徊在tableView的頂部,第二,在UIView滑動縮小tableView的高度。沒有工作。