[英]“Unable to simultaneously satisfy constraints” when debugging
Below is the error message I receive in the debug area. 以下是我在调试区域中收到的错误消息。 It runs fine and nothing is wrong except that I receive this error.
它运行正常,除了我收到此错误外,没有什么错。 Would this prevent apple accepting the app?
这会阻止苹果接受该应用程序吗? How do I fix it?
我如何解决它?
( "<NSLayoutConstraint:0x7f9bdaf58890 UIView:0x7f9bdaf484e0.leading == UIView:0x7f9bdaf56e30.leadingMargin + 34>", "<NSLayoutConstraint:0x7f9bdaf58930 UIView:0x7f9bdaf56e30.trailingMargin == UIView:0x7f9bdaf484e0.trailing + 34>", "<NSLayoutConstraint:0x7f9bdaf58980 H:[UIView:0x7f9bdaf484e0(300)]>", "<NSLayoutConstraint:0x7f9bdaf5bfc0 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7f9bdaf56e30(375)]>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x7f9bdaf58980 H:[UIView:0x7f9bdaf484e0(300)]>
I guess this happens in a UITableView
on an iPhone 6. 我猜这发生在iPhone 6的
UITableView
。
Since cells reach from the left edge of the tableView to the right edge the cells need to be 375 points wide. 由于单元格从tableView的左边缘到达右边缘,因此单元格需要为375点宽。 The UITableView adds the
UIView-Encapsulated-Layout-Width
constraint to achieve this. UITableView添加了
UIView-Encapsulated-Layout-Width
约束来实现此目的。
The constraints you added yourself |-34-[centerView(=300)]-34-|
您添加的约束条件
|-34-[centerView(=300)]-34-|
will create a cell width of 368 points. 将创建一个368点的单元格宽度。
Since 368 != 375 this won't work. 由于368!= 375,因此无法使用。
You have a couple of options. 您有两种选择。
|-34-[centerView(>=300)]-34-|
|-34-[centerView(>=300)]-34-|
|-34-[centerView]-34-|
|-34-[centerView]-34-|
, this will lead to a 307 pt wide view on iPhone 6, on iPhone 6s it will be 346 points wide and on iPhone 5 it'll be 252 points wide. As you said the app works if the systems breaks the width=300 constraint, so you can just delete that constraint yourself. 如您所说,如果系统打破width = 300约束,则该应用程序将运行,因此您可以自己删除该约束。 If it works without that constraint there is no point in having it.
如果没有限制,它就没有意义。
Having two edge-distance constraints AND a width constraints at the same time doesn't make sense and defeats the purpose of auto layout. 同时具有两个边缘距离约束和一个宽度约束没有意义,并且违反了自动布局的目的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.