码迷,mamicode.com
首页 > 移动开发 > 详细

【iOS入门】mesonry 更新约束注意点

时间:2020-01-13 18:22:27      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:temp   布局   method   col   ble   center   sed   直接   中间   

练习UI布局

技术图片

 

 masonry 把下划线View移动左边。

开始时对齐中间的 lable ,点击时移动到对应lable下面。

使用方法:

    [indicator mas_updateConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(curCurTab);
    }];
    

直接报错:

[LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you dont want. 
    Try this: 
        (1) look at each constraint and try to figure out which you dont expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<MASLayoutConstraint:0x600002860660 UILabel:0x7feeda8202e0.width == 60>",
    "<MASLayoutConstraint:0x600002860060 UILabel:0x7feeda820070.width == 60>",
    "<MASLayoutConstraint:0x600002860840 UILabel:0x7feeda820070.right == UILabel:0x7feeda8202e0.left>",
    "<MASLayoutConstraint:0x600002860cc0 UIView:0x7feeda820f10.centerX == UILabel:0x7feeda8202e0.centerX>",
    "<MASLayoutConstraint:0x600002845560 UIView:0x7feeda820f10.centerX == UILabel:0x7feeda820070.centerX>"
)

Will attempt to recover by breaking constraint 
<MASLayoutConstraint:0x600002860660 UILabel:0x7feeda8202e0.width == 60>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2020-01-13 17:08:47.697034+0800 UITabBarControllerTest[62772:3586985] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you dont want. 
    Try this: 
        (1) look at each constraint and try to figure out which you dont expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<MASLayoutConstraint:0x600002860060 UILabel:0x7feeda820070.width == 60>",
    "<MASLayoutConstraint:0x600002860840 UILabel:0x7feeda820070.right == UILabel:0x7feeda8202e0.left>",
    "<MASLayoutConstraint:0x600002860cc0 UIView:0x7feeda820f10.centerX == UILabel:0x7feeda8202e0.centerX>",
    "<MASLayoutConstraint:0x600002845560 UIView:0x7feeda820f10.centerX == UILabel:0x7feeda820070.centerX>"
)

 

原因:

参考这个https://blog.csdn.net/captainjackNO1/article/details/51275161

mas_updateConstraints方法里对同一个布局的理解就是相对的元素也是一致才行,即这里这样做才算一次update

A->B A->B的变化
A->C 是一个新的约束

 

或者 

使用:

mas_remakeConstraints 重做约束。
    [indicator mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(curCurTab);
        make.bottom.equalTo(tabLayout.mas_bottom).offset(-2);
        make.height.equalTo(@3);
        make.width.equalTo(@15);
    }];

【iOS入门】mesonry 更新约束注意点

标签:temp   布局   method   col   ble   center   sed   直接   中间   

原文地址:https://www.cnblogs.com/mamamia/p/12188241.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!