2013-08-29 44 views
9

UIWindow具有專用方法_autolayoutTrace,可幫助您找到隱蔽的佈局。這是非常好的和方便的,並輸出這樣的東西:[[UIWindow keyWindow] _autolayoutTrace]的輸出中星號(*)的含義]

*<UIWindow:0x13436fd0> - AMBIGUOUS LAYOUT 
| *<UIView:0xd5e0b30> 
| | *<PbJellyContentContainerView:0xd5e0ff0> 
| | | *<UIView:0x20710ee0> 
| | | | *<PbMapContainerView:0x20710c90> 
| | | | | <MKMapView:0x2070df70> 
| | | | | | <UIView:0xd1cca20> 
| | | | | | | <MKBasicMapView:0xd1cd020> 
.... 

我的問題是不是任何含糊不清。這是關於一些意見前面的星號。它的含義是什麼?

我的猜測是它會標記所有使用自動佈局的視圖。但是系統如何確定這一點?

更新:

看來,星號標記,要麼至少有一個約束集或有至少有一個約束集子視圖所有視圖。

將未設置約束的translatesAutoresizingMaskIntoConstraints設置爲false不會給出星號。

+0

當然,但我不能還納;( – Klaas

+0

你能告訴我怎麼你這個我已經試過[一個UIWindow keyWindow] _autolayoutTrace],但它不給我這樣的痕跡 –

+0

@MehulThakkar只需在調試控制檯中輸入'po [[UIWindow keyWindow] _autolayoutTrace]'。 – Klaas

回答

7

這是傳說爲-[UIView _autolayoutTrace]WWDC 2015 session #219 video在31:00

* - is laid out with auto layout 
+ - is laid out manually, but is represented in the layout engine because translatesAutoresizingMaskIntoConstraints = YES 
• - layout engine host 
0

我明白了你的意思,我認爲是這樣,*適用於你可以應用Autolay的組件。 我意味着如果有按鈕,然後它會顯示它作爲

*<UIRoundedRectButton:0x1f053a50> 
| | | <UIGroupTableViewCellBackground:0x1f053b20> 
| | | <UIImageView:0x1f0542f0> 
| | | <UIButtonLabel:0x1f053db0> 

這意味着rectButton是你把你可以申請自動佈局上,而其他3下會自動進行佈局本身。

*將只顯示,如果在你的用戶界面,包括至少一個組件都有UIAutolayout ON,如果所有的組件是沒有自動佈局,然後將其理解整個的UIView作爲單一成分,並不會顯示*