开发经验总结

delims 于 2019-08-22 发布

总结一下开发过程遇到的特殊情况,需要注意的点

iOS9-iOS11的系统使用Xib布局cell,设置UITableViewAutomaticDimension自动计算高度时会提示如下的错误。解决办法,可以给其中一个高度约束设置priority为小于1000。

2019-08-22 13:29:16.973702+0800 BoChuang[58487:1511846] [LayoutConstraints] 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:0x600000092890 UIImageView:0x7fe453f7dfe0.height == 48>",
    "<NSLayoutConstraint:0x600000092520 UIView:0x7fe453f37590.height == 10>",
    "<NSLayoutConstraint:0x60000008eb50 UIImageView:0x7fe453f7dfe0.top == UITableViewCellContentView:0x7fe453f55220.top + 10>",
    "<NSLayoutConstraint:0x600000094230 UIView:0x7fe453f37590.top == UIImageView:0x7fe453f7dfe0.bottom + 10.5>",
    "<NSLayoutConstraint:0x600000094280 UITableViewCellContentView:0x7fe453f55220.bottom == UIView:0x7fe453f37590.bottom>",
    "<NSLayoutConstraint:0x600000094aa0 UITableViewCellContentView:0x7fe453f55220.height == 78.6667>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x600000092890 UIImageView:0x7fe453f7dfe0.height == 48>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.