【发布时间】:2018-08-01 01:20:40
【问题描述】:
我收到以下关于自动布局的警告。
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:0x604000285230 H:|-(64)-[UILabel:0x7fc908d51ba0] (active, names: '|':UIView:0x7fc908d52020 )>",
"<NSLayoutConstraint:0x6040002854b0 H:[UIView:0x7fc908c59f60]-(0)-| (active, names: '|':UIView:0x7fc908d52020 )>",
"<NSLayoutConstraint:0x604000285000 H:[UILabel:0x7fc908d51ba0]-(9)-[UIView:0x7fc908c59f60] (active)>",
"<NSLayoutConstraint:0x6040002855f0 UIView:0x7fc908c59f60.width == 160 (active)>",
"<NSLayoutConstraint:0x60400028a1e0 'UIView-Encapsulated-Layout-Width' UIView:0x7fc908d52020.width == 0 (active)>"
)
但是,我可以通过将尾随约束优先级设置为 999 来消除警告。这似乎消除了警告,并且布局没有任何变化。这样做可以吗?或者这会导致任何问题吗?
【问题讨论】:
-
要正确解决这个问题,你需要弄清楚这个约束来自哪里:
<NSLayoutConstraint:0x60400028a1e0 'UIView-Encapsulated-Layout-Width' UIView:0x7fc908d52020.width == 0 (active)>
标签: ios objective-c autolayout constraints