砌体:topLayoutGuide / bottomLayoutGuide导致iOS9崩溃

时间:2015-09-17 00:10:05

标签: autolayout ios9 masonry

Masonry:topLayoutGuide / bottomLayoutGuide导致iOS9崩溃

演示代码:

[topView makeConstraints:^(MASConstraintMaker *make) {
    UIView *topLayoutGuide = (id)self.topLayoutGuide;

    // topLayoutGuide cause exception
    make.top.equalTo(topLayoutGuide.mas_bottom);

    make.left.equalTo(self.view);
    make.right.equalTo(self.view);
    make.height.equalTo(@40);
}];

1 个答案:

答案 0 :(得分:1)

我认为您应该使用self.mas_topLayoutGuide,因为self.topLayoutGuide不是UIView对象。

[topView makeConstraints:^(MASConstraintMaker *make) {

    make.top.equalTo(self.mas_topLayoutGuide);

    make.left.equalTo(self.view);
    make.right.equalTo(self.view);
    make.height.equalTo(@40);
}]