更新Xcode11.1后碰到的一个小问题(Masonry)

问题如下:原来设计中有一个按钮暂时没有使用,要求隐藏起来。然后我就把它添加到self.view的代码给注释掉了。约束仍然保留(代码如下)。在更新到Xcode11.1后,这样的情况会在进入界面时发生闪退现象。打断点后会崩溃在Masonry库里面。

   _btnSave = [UIButton buttonWithType:UIButtonTypeCustom];
    _btnSave.layer.cornerRadius = 10.0f;
    [_btnSave.layer masksToBounds];
    [_btnSave setImage:[UIImage imageNamed:@"icon_download_net"] forState:UIControlStateNormal];
    [_btnSave setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_btnSave addTarget:self action:@selector(saveToAlbum) forControlEvents:(UIControlEventTouchUpInside)];
    //[self.view addSubview:_btnSave];
    
    _btnDelete = [UIButton buttonWithType:UIButtonTypeCustom];
    _btnDelete.layer.cornerRadius = 10.0f;
    [_btnDelete.layer masksToBounds];
    [_btnDelete setImage:[UIImage imageNamed:@"icon_album_delete"] forState:UIControlStateNormal];
    [_btnDelete setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_btnDelete addTarget:self action:@selector(delete) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:_btnDelete];
    
    //**********************************************************************************//
    
    [self.player mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.centerY.equalTo(self.view);
        make.width.mas_equalTo(SCREEN_WIDTH);
        make.height.mas_equalTo(SCREEN_WIDTH * 9 / 16);
    }];
    
    [self.btnPause mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.centerY.equalTo(self.view);
        make.width.mas_equalTo(60);
        make.height.mas_equalTo(60);
    }];
    
    [self.btnSave mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.btnDelete.mas_left).offset(-15);
        make.width.mas_equalTo(40);
        make.bottom.equalTo(self.view.mas_bottom).offset(-10);
        make.height.mas_equalTo(40);
    }];
    
    [self.btnDelete mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.view.mas_right).offset(-15);
        make.width.mas_equalTo(40);
        make.bottom.equalTo(self.view.mas_bottom).offset(-10);
        make.height.mas_equalTo(40);
    }];

报错截图如下:


更新Xcode11.1后碰到的一个小问题(Masonry)_第1张图片
报错信息.png

修改方案:将约束信息一起注释掉。

你可能感兴趣的:(更新Xcode11.1后碰到的一个小问题(Masonry))