20170729 layout And constraint

系统报错
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'couldn't find a common superview for > and >'
*** First throw call stack:

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self configMessInterfaceViewWithTitle: @"确认下单" ];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.view.backgroundColor = CHBackgroundColor;
    [self.view addSubview: self.payingBillsTableView ];
    [self.view addSubview: self.payingBillsBottomView ];

}



- (OrderBottomView *)payingBillsBottomView{
    if ( !_payingBillsBottomView ){
        _payingBillsBottomView = [[OrderBottomView alloc] initWithFrame: CGRectMake(0, kScreenHeight-50, kScreenWidth, 50 ) ];
    }
    return _payingBillsBottomView;
}

@implementation OrderBottomView

- (instancetype)init {
    if (self = [super init]) {
        self.backgroundColor = [UIColor whiteColor];
        [self setupView];
    }
    return self;
}



- (void)layoutSubviews {
    [super layoutSubviews];
    

    [self.payoffButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.bottom.equalTo(self);
        make.width.equalTo(@110);
    }];

    [self.totalPriceLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.right.equalTo(self.payoffButton.mas_left).offset(-16);
    }];
    
    [self.separateLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(self);
        make.height.equalTo(@0.3);
    }];
}

我觉得 是因为 ,
控件分配了 frame , 还没 add到 父视图上,控件的 子视图 layout constraints.
就GG.
约束 前, 必须 addSubview:

你可能感兴趣的:(20170729 layout And constraint)