【iOS】Masonry 自动布局 MASViewConstraint.m:207 错误

时间:2022-06-02 00:21:44

问题详情:

Assertion failure in -[MASViewConstraint addConstraintWithLayoutAttribute:], ~/Pods/Masonry/Masonry/MASViewConstraint.m:

报错原因:

make.right.equalTo([_imageView superview]).right.with.offset(-);
make.bottom.equalTo([_imageView superview]).bottom.with.offset(-);

当时想当然的就这么写了,仔细查看了 Github 链接,才发现了自己的失误。正确写法如下:

make.right.equalTo([_imageView superview].mas_right).with.offset(-);
make.bottom.equalTo([_imageView superview].mas_bottom).with.offset(-);

PS: 报此错误的的还可能是不小心把 with 误写成 width