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


    练习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 don't want. 
        Try this: 
            (1) look at each constraint and try to figure out which you don't 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 don't want. 
        Try this: 
            (1) look at each constraint and try to figure out which you don't 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);
        }];
  • 相关阅读:
    微信公众平台接口获取时间戳为10位,java开发需转为13位
    redis实现哨兵机制
    redis配置主从复制
    C 语言字符 和字符串输出
    C 小写字母编程大写并输出
    C语言计算机器运行时间
    C 猜数游戏
    C 产生随机码 (输入数字来产生)
    C 产生随机码
    C 语言链表操作例程 (待完善)
  • 原文地址:https://www.cnblogs.com/mamamia/p/12188241.html
Copyright © 2020-2023  润新知