简体   繁体   English

Xcode中的灰色变暗

[英]Contraints greyed-out in Xcode

I am trying to debug+understand autolayout constraints and I notice that when debugging the view with xcode (using the cool layer thing) I noticed that on one element in the view the constraints look like this 我正在尝试调试+了解autolayout约束,我注意到在用xcode调试视图时(使用酷层事物)我注意到在视图中的一个元素上,约束看起来像这样

在此输入图像描述

and the view is indeed ignoring these constraints. 而观点确实忽略了这些限制。

All constraints have the same priority (1000) since I want them all. 所有约束具有相同的优先级(1000),因为我想要它们。 All constraints were made with interface builder and not through code, and there are not warning or conflicts in IB. 所有约束都是使用接口构建器而不是通过代码进行的,并且IB中没有警告或冲突。

But in runtime I do see this 但在运行时我确实看到了这一点

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:0x79684f10 V:[UIImageView:0x79686800(>=160)]>",
    "<NSLayoutConstraint:0x7968a310 V:[UIImageView:0x79686800]-(130.5)-|   (Names: '|':UIView:0x79686790 )>",
    "<NSLayoutConstraint:0x7968a340 V:|-(0)-[UIImageView:0x79686800]   (Names: '|':UIView:0x79686790 )>",
    "<NSLayoutConstraint:0x796997b0 'UIView-Encapsulated-Layout-Height' V:[CoverCell:0x79686570(192)]>",
    "<NSAutoresizingMaskLayoutConstraint:0x7969cd30 h=-&- v=-&- UIView:0x79686790.height == CoverCell:0x79686570.height>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x79684f10 V:[UIImageView:0x79686800(>=160)]>

So from this I understand that some rules conflict, but I'm not sure how to read this 所以我从中了解到一些规则存在冲突,但我不确定如何阅读

the >=160 is a rule on the UIImageView so it would have height of atleast 160 and 130.5 is the bottom padding of the imageview (so when using systemLayoutSizeFittingSize:UILayoutFittingCompressedSize the height won't be 0. So the minimum height for the entire cell is 160+130.5) >=160是UIImageView上的规则,所以它的高度至少为160,而130.5是imageview的底部填充(所以当使用systemLayoutSizeFittingSize:UILayoutFittingCompressedSize ,高度不会是0.所以整个单元的最小高度是160 + 130.5)

The rest of the error I don't understand. 剩下的错误我不明白。

What is wrong with the constraints and why do constraint conflicts occur in runtime and not in IB? 约束有什么问题,为什么约束冲突发生在运行时而不是IB?

XCode 6 now supports different layouts. XCode 6现在支持不同的布局。 This greyed out constraints exist in Compact Width | 紧凑宽度|中存在这种灰色约束 Any Height layout, for example, but you currently editing Any Width | 例如, 任何高度布局,但您当前正在编辑任何宽度| Any Height . 任何高度

More detailed: Storyboard View Elements Greyed Out 更详细: 故事板视图元素灰色

It depends. 这取决于。 If you don't use size classes the grey ones are the removed ones. 如果你不使用大小类,灰色的是删除的。 And you need to remove them second time. 你需要第二次删除它们。 No matter how stupid it sounds. 不管它听起来多么愚蠢。

If you use size classes, it means that your current size class is different than for greyed constraint. 如果使用大小类,则表示当前大小类与灰色约束不同。 (however the first scenario is also possible...) (但第一种情况也是可能的......)

In your case it looks like this is the first case. 在你的情况下,这似乎是第一种情况。 You need to remove greyed constraints once again. 您需要再次删除灰色约束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM