0
我有執行期間改變約束值(其爲height
值),從19至45GOT「不能同時滿足約束」消息,分配值NSLayoutConstraints.constant
要做到這一點後,我添加了約束屬性。
@IBOutlet weak var cnst: NSLayoutConstraint!
然後我寫了下面一個。
cnst.constant = 45
然後我得到這個消息:
2016-08-04 11:19:49.352 IMOZOMO[45034:538195] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x7ff278c27e70 V:[UIView:0x7ff278c27f40(45)]>",
"<NSLayoutConstraint:0x7ff27a9b1ee0 V:[UIView:0x7ff278c27f40(19)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7ff278c27e70 V:[UIView:0x7ff278c27f40(45)]>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
好像以前的財產仍和指定對象的高度並沒有改變。我認爲高度爲19的約束可能會消失。
如何更改NSLayoutConstraint的常量值?
您是否100%確定您沒有兩個約束來指定「19」的高度?因爲你調整常數的方式是可以的,所以一定是其他問題。 – paulvs
@paulvs對象還有一些其他限制,但只有其中一個限制了它的高度。 –
看起來你的其他約束與新的高度相沖突。看看影響'.y'的約束,看看什麼是不需要的? –