在使用第三方库ZLSwipeableView的时候,在定义的card view的时候使用的是Masonry来自动布局,结果就发现,对每一个定义在card view内部,使用Marsonry布局的空间,都出现了如下的警告:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15[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.
(
"<MASLayoutConstraint:0x6080000bd8e0 UILabel:0x7fabebd48250.width == 199>",
"<MASLayoutConstraint:0x6000002a8b80 UILabel:0x7fabebd48250.width == 208.687>"
)
Will attempt to recover by breaking constraint
<MASLayoutConstraint:0x6000002a8b80 UILabel:0x7fabebd48250.width == 208.687>
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.
找了很久,都没有找到第二个约束是在哪里设置的,如果有人知道的话,请留言指教。
至于解决方案,就是对card view内部使用Masonry布局的空间添加布局优先级,就可以移除这些警告了。
例如:1
2
3[self.backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
修改为:1
2
3[self.backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self).priorityHigh();
}];