我應該如何在NSSplitView
子視圖中使用自動佈局約束?NSSplitView和自動佈局
我NSSplitView
子視圖有3子視圖:topPane
,tableContainer
和bottomPane
和我這樣設置約束:
NSDictionary* views = NSDictionaryOfVariableBindings(topPane, tableContainer, bottomPane);
for (NSView* view in [views allValues]) {
[view setTranslatesAutoresizingMaskIntoConstraints:NO];
}
[myView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[topPane(34)][tableContainer][bottomPane(24)]|"
options:0
metrics:nil
views:views]];
[mySplitView addSubview:myView];
而得到這個控制檯:
Unable to simultaneously satisfy constraints:
(
"<NSLayoutConstraint:0x7fd6c4b1f770 V:[NSScrollView:0x7fd6c4b234c0]-(0)-[CPane:0x7fd6c4b2fd10]>",
"<NSLayoutConstraint:0x7fd6c4b30910 V:[CPane:0x7fd6c4b2f870(34)]>",
"<NSLayoutConstraint:0x7fd6c4b30770 V:|-(0)-[CPane:0x7fd6c4b2f870] (Names: '|':NSView:0x7fd6c4b22e50)>",
"<NSLayoutConstraint:0x7fd6c4b212f0 V:[CPane:0x7fd6c4b2fd10]-(0)-| (Names: '|':NSView:0x7fd6c4b22e50)>",
"<NSLayoutConstraint:0x7fd6c4b2f910 V:[CPane:0x7fd6c4b2f870]-(0)-[NSScrollView:0x7fd6c4b234c0]>",
"<NSLayoutConstraint:0x7fd6c4b21290 V:[CPane:0x7fd6c4b2fd10(24)]>",
"<NSAutoresizingMaskLayoutConstraint:0x7fd6c3630430 h=--& v=--& V:[NSView:0x7fd6c4b22e50(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fd6c4b1f770 V:[NSScrollView:0x7fd6c4b234c0]-(0)-[CPane:0x7fd6c4b2fd10]>
我覺得<NSAutoresizingMaskLayoutConstraint:0x7fd6c3630430 h=--& v=--& V:[NSView:0x7fd6c4b22e50(0)]>
原因這一點,但我無法重置自動調整屏蔽,因爲NSSplitView
會設置它。
在拆分視圖中使用自動佈局的最佳方法是什麼?有沒有辦法處理分割視圖子視圖的最小/最大大小與自動佈局沒有NSSplitViewDelegate
?
同樣的問題在這裏。我把所有東西都放在了IB中,而不是編程,但是有類似的調試輸出,包括'NSAutoresizingMaskLayoutConstraint'。 –
這似乎是固定在10.8以下,但是如您在10.7下注意到的那樣破壞了。在10.8中,您可以設置Xcode中分割視圖的內容視圖的最小高度和寬度(無論如何4.5.2)。無法在10.7以下完成此操作,而在10.8中創建的應用程序仍然無法在10.7中正常工作 – Dad
通常需要在10.8以上工作,但大多數視圖的子視圖之間需要指定約束 - 而不是supre - 否則您將得到* Unable以同時滿足*錯誤.. – Jay