【发布时间】:2016-11-09 14:30:13
【问题描述】:
我有奇怪的行为。我的整个视图控制器看起来像这样(垂直顺序):
- UILabel,
- UITableView,
- UIView(需要时会滑入&滑出)。 [见附注]
我在 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()
}
有没有人遇到过这样的怪事?
附言尝试了两个版本:第一个,滑动 UIView 在 tableView 上悬停进出,第二个在 UIView 中滑动正在缩小 tableView 的高度。没有任何效果。
【问题讨论】:
标签: ios swift uitableview uiview autolayout