Masoniryを使って自動レイアウトを作ります.

1509 ワード

サードパーティライブラリZLSwipeablewiwを使用する際に定義されたカードビューではMasoniryを使って自動レイアウトをしていますが、各定義はcard viewの内部にあり、Marsoryレイアウトの空間を使って、次のように警告されています.
[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. 
(
    "<0x6080000bd8e0 uilabel:0x7fabebd48250.width="=">",
    "<0x6000002a8b80 uilabel:0x7fabebd48250.width="=">"
)

Will attempt to recover by breaking constraint 
<0x6000002a8b80 uilabel:0x7fabebd48250.width="=">

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.
探してみましたが、二つ目の制約はどこに設置されていますか?知っている人がいたら、メッセージを残してください.
解決策としては、カードビューの内部にMasoniryレイアウトを使用した空間にレイアウト優先度を追加することで、これらの警告を削除することができます.たとえば:
    [self.backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
変更先:
    [self.backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self).priorityHigh();
    }];