ios代码添加NSLayoutConstraint的问题

Q1

在工作中发现,需要代码添加NSLayoutConstraint的时候,发现出现如下问题:

Unable to simultaneously satisfy constraints.

Probably at least one of the constraints in the following list is one you don't want

解决方案: 设置view的translatesAutoresizingMaskIntoConstraints的属性为NO即可解决


Q2

出现如下问题:The view hierarchy is not prepared for the constraint:

解决方案:先将view添加到superview上,然后再添加NSLayoutConstraint约束条件即可解决


你可能感兴趣的:(ios代码添加NSLayoutConstraint的问题)