簡體   English   中英

iOS:無法同時滿足約束

[英]iOS: Unable to simultaneously satisfy constraints

對於這個問題,我已經看到了普遍的反應,即沒有正確設置約束。 但是,我已經解決了Interface Builder中的所有歧義,所有約束似乎都可以。 我不確定接下來要檢查什么。 我什至不知道它來自哪里。 我沒有在代碼中設置任何約束。

我該怎么辦才能弄清楚它的形式? 如果Interface Builder沒有報告任何歧義,可能是什么原因?

具體錯誤如下:

2014-06-28 19:54:36.070 Prayer Feed[4497:60b] 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:0x178290360 H:[UIImageView:0x13ee32490(20)]>",
    "<NSLayoutConstraint:0x1782904f0 UITableViewCellContentView:0x178166840.centerX == UIImageView:0x13ee32490.centerX + 62>",
    "<NSLayoutConstraint:0x178290540 H:|-(52)-[UIImageView:0x13ee32490]   (Names: '|':UITableViewCellContentView:0x178166840 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x170286d60 h=--& v=--& H:[UITableViewCellContentView:0x178166840(247)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x178290360 H:[UIImageView:0x13ee32490(20)]>

我知道代碼中的兩個地方都有UIImageView限制為20x20,但是IB再次告訴我一切都很好。

這是問題所在的部分:

<NSAutoresizingMaskLayoutConstraint:0x170286d60 h=--& v=--& H:[UITableViewCellContentView:0x178166840(247)]>

該遮罩需要關閉。

我認為對於具有約束的IB元素,默認情況下該掩碼處於關閉狀態。 所以我假設您在代碼中做了一些事情。 您可以使用以下代碼將其關閉:

contentView.translatesAutoresizingMaskIntoConstraints = NO

如果這真的只是所有IB,那么我想知道您在創建表單元格時使用了什么代碼。

暫無
暫無

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

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