簡體   English   中英

無法同時滿足 Swift 中的約束運行時錯誤

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

我的 ios(UIKit) 應用程序在運行時收到此錯誤。 它來自UITableView 該應用程序運行時不會出現約束錯誤並具有預期的行為。

我已經看到有關相同錯誤的其他問題,但我應該保留這個錯誤嗎?

錯誤部分是抱怨我的兩個UITableView通過一個單元格連接(第一個表使用 1.6 作為縱橫比,第二個視圖使用 0.55 作為寬度/大小)。 我不確定如何解決這個問題,因為沒有問題,而且這些視圖是分開的。

[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.

您似乎對同一視圖設置了兩次約束:

"<NSLayoutConstraint:0x600001575860 UIImageView:0x7f8795f474f0.width == 1.6*UIImageView:0x7f8795f474f0.height (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