如何在運行時更改約束優先級 - How can I change constraints priority in run time

問題:

I have a view which has dynamic height and I am trying to change this view height priority in run time.我有一個具有動態高度的視圖,我正在嘗試在運行時更改此視圖高度優先級。

Here is my part of code;這是我的代碼部分;

if (index == 0) {

    surveyViewHeightConstraint.constant = 0;
    surveyViewHeightConstraint.priority = 1000;

} else if (index == 1) {

    surveyViewHeightConstraint.constant = 163;
    surveyViewHeightConstraint.priority = 500;

}

I am changing index with a button action.我正在通過按鈕操作更改索引。 When I run this code, I am getting this error:當我運行此代碼時,出現此錯誤:

*** Assertion failure in -[NSLayoutConstraint setPriority:], /SourceCache/Foundation/Foundation-1141.1/Layout.subproj/NSLayoutConstraint.m:174

What is my mistake in here?我在這裏有什麼錯誤?


解決方案:

參考: https://stackoom.com/en/question/26qx1
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章