pod导入Masonry使用Margin闪退问题

2018-11-02  本文已影响40人  小時間光
  //==============================
    UIView *redView = [[UIView alloc]init];
    [self.view addSubview:redView];
    [redView mas_makeConstraints:^(MASConstraintMaker *make) {
        //
        make.top.mas_equalTo(self.view.mas_topMargin);
        //
        make.left.mas_equalTo(self.view.mas_left).with.offset(0);
        //
        make.right.mas_equalTo(self.view.mas_right).with.offset(0);
        //
        make.bottom.mas_equalTo(self.view.mas_bottomMargin);
    }];
    redView.backgroundColor = [UIColor redColor];

报错

-[UIView mas_topMargin]: unrecognized selector sent to instance

解决方法,在pod中修改Masonry最低支持版本为iOS 8.0即可,

A12.png

运行成功,


iPhone X

参考 Masonry v1.1.0 crash with UIView margins #461

参考Stack Overflow Set deployment target for CocoaPods's pod

上一篇 下一篇

猜你喜欢

热点阅读