0
当我尝试在创建约束后立即更新snapkit约束时,出现Updated constraint could not find existing matching constraint to update
错误。我使用的代码如下:更新约束在UITableView snapkit上不起作用
let directionList = UITableView()
directionList.delegate = self
directionList.dataSource = self
directionList.tag = DIRECTIONS_TABLE_TAG
self.view.addSubview(directionList)
directionList.snp.makeConstraints{ (make) -> Void in
make.width.equalToSuperview()
make.top.equalTo(self.view.snp.bottom)
make.left.equalToSuperview()
make.right.equalToSuperview()
make.bottom.equalToSuperview().offset(-20)
}
directionList.snp.updateConstraints { (make) -> Void in
make.top.equalTo(self.topDarkBlue.snp.bottom)
}
你是什么意思只是常数?我在'UIView.animate'中使用updateConstraints,所以我需要将它保留为updateConstraints。 – SmedleyDSlap
NSLayoutConstraint的.constant属性。我不明白你为什么不能为UIView.animate使用makeConstraints;虽然我不清楚如果调用makeConstraints调用layoutIfNeeded。如果不是,则先调用约束条件,然后将self.view.layoutIfNeeded放入动画块中以触发自动布局重新计算和框架更改。 –