我試圖使用通常的刪除標籤並使用自動佈局調整所有內容的方法。 How to change label constraints during runtime。但是,我正在使用UITableView 標頭。當在UITableView標題中將標籤約束設置爲0時,Autolay失敗
當我設定的標籤之一的高度約束:
self.labelAHeight.constant = 0;
結果是:
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. (Note: If you're seeing
NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the
UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0xb0faad0 V:[UILabel:0xb0fa830(0)]>",
"<NSLayoutConstraint:0xb0772a0 V:[UILabel:0xb077300(58)]>",
"<NSLayoutConstraint:0xb076cc0 V:|-(0)-[UILabel:0xb0fa830] (Names: '|':UIView:0xb077660)>",
"<NSLayoutConstraint:0xb076c90 V:[UILabel:0xb077300]-(0)-| (Names: '|':UIView:0xb077660)>",
"<NSLayoutConstraint:0xb076c00 V:[UILabel:0xb0fa830]-(0)-[UILabel:0xb077300]>",
"<NSAutoresizingMaskLayoutConstraint:0xb06f030 h=--& v=--& V:[UIView:0xb077660(119)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0xb0772a0 V:[UILabel:0xb077300(58)]>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h>
may also be helpful.
我試圖[self.labelA setTranslatesAutoresizingMaskIntoConstraints:NO]
這於事無補。我試過[self.table.tableHeaderView setTranslatesAutoresizingMaskIntoConstraints:NO]
與*** Assertion failure in -[UITableView layoutSublayersOfLayer:], /SourceCache/UIKit_Sim/UIKit-2935.137/UIView.m:8794
碰撞。也許,我在錯誤的地方做了這個(就在設置約束條件之前)。
似乎並不重要的約束變化發生在哪裏,例如, viewDidLoad
或按鈕處理程序。
它看起來好像標題想要達到一定的高度(<NSAutoresizingMaskLayoutConstraint:0xb06f030 h=--& v=--& V:[UIView:0xb077660(119)]>
根據其內容),如果內容改變,自動佈局變得非常不高興。
任何人都可以幫助調試或建議如何解決它? (我試過儀器,但是被添加和刪除的所有約束困惑......)