美文网首页
20170729 layout And constraint

20170729 layout And constraint

作者: plantAtree_dAp | 来源:发表于2017-07-29 13:34 被阅读9次

    系统报错
    Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'couldn't find a common superview for <UIButton: 0x7ff167f7a580; frame = (0 0; 0 0); opaque = NO; layer = <CALayer: 0x6080004290c0>> and <OrderBottomView: 0x7ff167e63560; frame = (0 617; 375 50); layer = <CALayer: 0x61000022ff40>>'
    *** 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

          本文链接:https://www.haomeiwen.com/subject/hqtclxtx.html