gpt4 book ai didi

ios - 约束变化不起作用

转载 作者:行者123 更新时间:2023-11-28 19:58:20 24 4
gpt4 key购买 nike

我有一个 View ,其约束如下。

enter image description here

现在,当我按照以下方式更改为 contain 时:

     [cell addConstraint:[NSLayoutConstraint constraintWithItem:cell.view_label 
attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual
toItem:cell.view_label.superview
attribute:NSLayoutAttributeLeading multiplier:1.0 constant:60]];

[UIView animateWithDuration:0.2 animations:^{
[cell.view_label updateConstraints];
[cell.view_label.superview updateConstraints];
}];

//不工作

警告:

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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "", "" )

Will attempt to recover by breaking constraint

Break on objc_exception_throw to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful.

帮我解决这个问题

提前致谢

最佳答案

您正在那里添加一个 约束。旧的约束仍然存在,它不能同时满足这两个条件,因此出现警告。

您需要修改现有约束的constant 属性。做到这一点的最好方法是为它做一个导出。

关于ios - 约束变化不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25257704/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com