我有一个集合视图,每个单元格都有一个textView。这是我的textview约束设置
textView.topAnchor.constraint(equalTo: object1.bottomAnchor).isActive = true
textView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
...和我的textView的宽度和高度。
现在,由于某个if条件,我想将我的textView的topAnchor更改为对象2的bottomAnchor而不是对象1的bottomAnchor。然而,当我输入下面的代码时,我会得到"Will attempt to recover by breaking constraint"错误。
有人知道如何在已经设置好top anchor的情况下更改它的方法吗?
if (aCondition){
textView.topAnchor.constraint(equalTo: object2.bottomAnchor).isActive = true
}else{
textView.topAnchor.constraint(equalTo: object1.botttomAnchor).isActive = true
}