8
如何在运行时更改约束优先级
我有一个具有动态高度的视图,并且我试图在运行时更改此视图高度优先级。 这是我的代码部分; if (index == 0) { surveyViewHeightConstraint.constant = 0; surveyViewHeightConstraint.priority = 1000; } else if (index == 1) { surveyViewHeightConstraint.constant = 163; surveyViewHeightConstraint.priority = 500; } 我正在通过按钮操作更改索引。运行此代码时,出现此错误: *** Assertion failure in -[NSLayoutConstraint setPriority:], /SourceCache/Foundation/Foundation-1141.1/Layout.subproj/NSLayoutConstraint.m:174 我在这里有什么错?