xib中label多行显示的高度问题

用xib自定义cell时,给label的添加约束:(top:10,  leading:10,  trailing:10,  height:10)

注:label设置numberOfLines = 0, 多行显示的.

问题:

当用代码修改height的约束时,报下面的错.

不用代码修改height的约束时, 错误消失.???

解决方法:

删除height的约束,label会自适应,label的高度可以计算出来,用boundingRectWithSize

然后计算出cell的高度.

错误信息:

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.

(

""

""

""

""

""

""

""

""

""

""

""

""

""

)

Will attempt to recover by breaking constraint

""

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.

The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful.

你可能感兴趣的:(xib中label多行显示的高度问题)