UIWindow有一个私有方法_autolayoutTrace,它可以帮助您查找模糊布局。它非常漂亮和方便,并输出类似的东西:
*<UIWindow:0x13436fd0> - AMBIGUOUS LAYOUT
| *<UIView:0xd5e0b30>
| | *<PbJellyContentContainerView:0xd5e0ff0>
| | | *<UIView:0x20710ee0>
| | | | *<PbMapContainerView:0x20710c90>
| | | | | <MKMapView:0x2070df70>
| | | | | | <UIView:0xd1cca20>
| | | | | | | <MKBasicMapView:0xd1cd020>
....
我的问题不是关于任何歧义。这是关于一些视图前面的星号。它的含义是什么?
我的猜测是,它会标记所有使用自动布局的视图。但这个系统是如何决定这一点的呢?
更新:
星号似乎标记了所有至少有一个约束集的视图,或者具有至少有一个子视图的视图。
在不设置约束的情况下将translatesAutoresizingMaskIntoConstraints设置为false不会给出星号。
这是来自WWDC 2015会话#219视频的-[UIView _autolayoutTrace]
的图例,时间为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
我明白你的意思,我想是的,*
是用于可以应用Autolayout的组件。我的意思是,如果有按钮,它会显示为
*<UIRoundedRectButton:0x1f053a50>
| | | <UIGroupTableViewCellBackground:0x1f053b20>
| | | <UIImageView:0x1f0542f0>
| | | <UIButtonLabel:0x1f053db0>
这意味着rectButton是由您设置的,您可以在上面应用自动布局,而其他3个下面的将自动布局。
只有当UI中至少有1个组件的UIAutolayout为ON时,才会显示*
,如果所有组件都没有Autolayout,则它将整个UIView理解为单个组件,并且不会显示的*