且构网

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

无法同时满足约束

更新时间:2022-04-18 22:05:48

错误就是它所说的,并且非常明确您开始调试的说明。有两个冲突的约束。每个都指示自动布局运行时执行与另一个相矛盾的操作。

The error is what it says, and gives quite clear instructions for you to begin debugging. There are two constraints that conflict. Each instructs the Auto Layout runtime to do something that contradicts the other.

如果您是以编程方式创建和添加视图,则自动调整大小属性可能会自动转换为自动布局约束。

If you are creating and adding views programmatically, then chances are Auto Resizing attributes have been automatically translated to Auto Layout constraints.

因此,首先要尝试的是,使用以编程方式创建的视图,通过设置禁用此功能:

So, the first thing to try is, with your programmatically created views, disable this by setting:

myProgrammaticView.translatesAutoresizingMaskIntoConstraints = NO;