且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

以编程方式应用自动布局约束时无法同时满足约束

更新时间:2022-04-18 22:06:42

这意味着您的约束并非从每个角度都满足.例如,如果您有 50x50 大小的视图.它位于精确的中心.现在,如果您在容器中提供水平中心等约束和始终保持 0 与前缘(左边缘)距离的前导约束,则会产生歧义.它不能同时满足这两个约束.它是否可以保持在中心或它可以管理与前沿的 0 距离但两者都不能满足所以这会导致 无法同时满足约束这样的错误.

That means your constraints is not satisfy from every point of view. for example if you have view with 50x50 size. and it is positioned at exact center. now if you give constraints like horizontaly center in container and leading constraint like always keep 0 distance with leading edge (left edge) then it creates ambiguity. it can't satisfy both constraints. whether it can remains in center or it can manage 0 distance with leading edge but both can't satisfy so this give error like unable to simultaneously satisfy constraints.

因此,在您的情况下,请检查所有相关约束.如果任何约束不明确,则将其删除,如果缺少任何约束,则添加它.

So, in your case check your all related constraints. If any constraints ambiguity then remove it and any constrain is missing then add it.

希望这会有所帮助:)