简体   繁体   中英

iOS: Unable to simultaneously satisfy constraints

I've seen the common response to this question of not having constraints set up properly. However, I've worked through all of the ambiguities in Interface Builder, and all constraints seem OK. I'm not sure what to check next. I can't even tell where it is coming from. I'm not setting any constraints in code.

What can I do to figure out where it is coming form? What can be the cause if Interface Builder doesn't report any ambiguities?

Here's the specific error:

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

I know the two place in code where I have a UIImageView constrained to 20x20, but again, IB tells me everything is fine.

This is the part where the problem is:

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

This mask needs to be turned off.

I think that mask is off by default for IB elements that have constraints. So I assume you made something in code. You can turn it off in code like this:

contentView.translatesAutoresizingMaskIntoConstraints = NO

If this is really all IB only then I would like to know what code you use around creating table cells.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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