2013-03-29 24 views
0

我正在全幀子視圖,(子視圖的幀=上海華的結合)NSLayoutConstraint錯誤:充分子視圖

我製成膨脹像以下

[self addConstraints:[NSLayoutConstraint 
          constraintsWithVisualFormat:@"H:|-0-[subview]-0-|" 
          options:NSLayoutFormatDirectionLeadingToTrailing 
          metrics:nil 
          views:NSDictionaryOfVariableBindings(subview)]]; 
[self addConstraints:[NSLayoutConstraint 
         constraintsWithVisualFormat:@"V:|-0-[subview]-0-|" 
         options:NSLayoutFormatDirectionLeadingToTrailing 
         metrics:nil 
         views:NSDictionaryOfVariableBindings(subview)]]; 

但是運行時錯誤occus,所示的下列錯誤。

"<NSAutoresizingMaskLayoutConstraint:0x1001bb700 h=--& v=--& H:[IUView:0x10015dcc0(960)]>", 
"<NSLayoutConstraint:0x1001911d0 H:|-(0)-[IUBGView:0x1001783f0] (Names: '|':IUView:0x10015dcc0)>", 
"<NSLayoutConstraint:0x1001910e0 H:[IUBGView:0x1001783f0]-(0)-| (Names: '|':IUView:0x10015dcc0)>", 
"<NSLayoutConstraint:0x10017bbf0 H:|-(0)-[NSImageView:0x100160050] (Names: '|':IUBGView:0x1001783f0)>", 
"<NSLayoutConstraint:0x10015d7f0 H:[NSImageView:0x100160050]-(0)-| (Names: '|':IUBGView:0x1001783f0)>", 
"<NSAutoresizingMaskLayoutConstraint:0x1001a6a80 h=--& v=--& H:[NSImageView:0x100160050(0)]>" 

Will attempt to recover by breaking constraint

Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens. And/or, break on objc_exception_throw to catch this in the debugger.

你能解釋我錯過了什麼嗎?

+1

搜索**「將嘗試打破約束,以恢復」在計算器上帶來了40多個類似的問題** ....你有沒有考慮在你的問題說明到目前爲止你已經嘗試過什麼,以及爲什麼這些別不適用你的情況嗎? – Jay

回答

1

看來,你不轉的你手工創建的意見「translatesAutoresizingMaskInotConstraints」功能。

someView.translatesAutoresizingMaskIntoConstraints = NO; 

如果不設置爲NO,那麼iOS的轉換彈簧-和支柱(例如自動調整大小面具)設置限制。這些限制與您使用可視格式語言進行的限制相沖突。

每當你看到這個類的NSAutoresizingMaskLayoutConstraint「在constaints錯誤輸出,那麼可以肯定你沒有關閉轉換。

好的做法是,每查看您創建編程,還進而轉化的。