簡體   English   中英

Xcode中的灰色變暗

[英]Contraints greyed-out in Xcode

我正在嘗試調試+了解autolayout約束,我注意到在用xcode調試視圖時(使用酷層事物)我注意到在視圖中的一個元素上,約束看起來像這樣

在此輸入圖像描述

而觀點確實忽略了這些限制。

所有約束具有相同的優先級(1000),因為我想要它們。 所有約束都是使用接口構建器而不是通過代碼進行的,並且IB中沒有警告或沖突。

但在運行時我確實看到了這一點

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)]>

所以我從中了解到一些規則存在沖突,但我不確定如何閱讀

>=160是UIImageView上的規則,所以它的高度至少為160,而130.5是imageview的底部填充(所以當使用systemLayoutSizeFittingSize:UILayoutFittingCompressedSize ,高度不會是0.所以整個單元的最小高度是160 + 130.5)

剩下的錯誤我不明白。

約束有什么問題,為什么約束沖突發生在運行時而不是IB?

XCode 6現在支持不同的布局。 緊湊寬度|中存在這種灰色約束 例如, 任何高度布局,但您當前正在編輯任何寬度| 任何高度

更詳細: 故事板視圖元素灰色

這取決於。 如果你不使用大小類,灰色的是刪除的。 你需要第二次刪除它們。 不管它聽起來多么愚蠢。

如果使用大小類,則表示當前大小類與灰色約束不同。 (但第一種情況也是可能的......)

在你的情況下,這似乎是第一種情況。 您需要再次刪除灰色約束。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM