简体   繁体   English

无法同时满足 Swift 中的约束运行时错误

[英]Unable to simultaneously satisfy constraints runtime error in Swift

I get this error in runtime for my ios(UIKit) application.我的 ios(UIKit) 应用程序在运行时收到此错误。 It is coming from UITableView .它来自UITableView The app runs without constraint errors and with the expected behavior.该应用程序运行时不会出现约束错误并具有预期的行为。

I've seen other questions regarding the same error but should I leave this error as it is?我已经看到有关相同错误的其他问题,但我应该保留这个错误吗?

The error is partially complaining about my two UITableView which are connected through a cell(First table uses 1.6 as the aspect ratio and second view uses .55 for width/size).错误部分是抱怨我的两个UITableView通过一个单元格连接(第一个表使用 1.6 作为纵横比,第二个视图使用 0.55 作为宽度/大小)。 I'm not sure how this can be fixed since there is no problem and these views are separate.我不确定如何解决这个问题,因为没有问题,而且这些视图是分开的。

[LayoutConstraints] 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. 
(
    "<NSLayoutConstraint:0x600001575860 UIImageView:0x7f8795f474f0.width == 1.6*UIImageView:0x7f8795f474f0.height   (active)>",
    "<NSLayoutConstraint:0x600001575770 V:|-(10)-[UIStackView:0x7f8795f47080]   (active, names: '|':UITableViewCellContentView:0x7f8795f46b50 )>",
    "<NSLayoutConstraint:0x600001575810 V:[UIStackView:0x7f8795f47080]-(10)-|   (active, names: '|':UITableViewCellContentView:0x7f8795f46b50 )>",
    "<NSLayoutConstraint:0x600001575950 UIImageView:0x7f8795f474f0.width == 0.55*UITableViewCellContentView:0x7f8795f46b50.width   (active)>",
    "<NSLayoutConstraint:0x600001573f20 'UISV-alignment' UILabel:0x7f8795f47210.bottom == UIImageView:0x7f8795f474f0.bottom   (active)>",
    "<NSLayoutConstraint:0x600001575ae0 'UISV-alignment' UILabel:0x7f8795f47210.top == UIImageView:0x7f8795f474f0.top   (active)>",
    "<NSLayoutConstraint:0x60000150cdc0 'UISV-canvas-connection' UIStackView:0x7f8795f47080.top == UILabel:0x7f8795f47210.top   (active)>",
    "<NSLayoutConstraint:0x60000150ce60 'UISV-canvas-connection' V:[UILabel:0x7f8795f47210]-(0)-|   (active, names: '|':UIStackView:0x7f8795f47080 )>",
    "<NSLayoutConstraint:0x600001575cc0 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x7f8795f46b50.height == 154.333   (active)>",
    "<NSLayoutConstraint:0x600001575c70 'UIView-Encapsulated-Layout-Width' UITableViewCellContentView:0x7f8795f46b50.width == 390   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x600001575860 UIImageView:0x7f8795f474f0.width == 1.6*UIImageView:0x7f8795f474f0.height   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

It seems you're setting constraints to the same view twice:您似乎对同一视图设置了两次约束:

"<NSLayoutConstraint:0x600001575860 UIImageView:0x7f8795f474f0.width == 1.6*UIImageView:0x7f8795f474f0.height (active)>", "<NSLayoutConstraint:0x600001575860 UIImageView:0x7f8795f474f0.width == 1.6*UIImageView:0x7f8795f474f0.height (active)>",

"<NSLayoutConstraint:0x600001575950 UIImageView:0x7f8795f474f0.width == 0.55*UITableViewCellContentView:0x7f8795f46b50.width (active)>" "<NSLayoutConstraint:0x600001575950 UIImageView:0x7f8795f474f0.width == 0.55*UITableViewCellContentView:0x7f8795f46b50.width (active)>"

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

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