gpt4 book ai didi

ios - 关闭 View 时发生自动布局内部错误

转载 作者:搜寻专家 更新时间:2023-10-30 23:15:18 24 4
gpt4 key购买 nike

当我驳回一些我有一些限制的观点时,我遇到了一个有趣的错误。

Auto layout internal error. Cannot find an outgoing row head for incoming head AppName.ViewName:0x7fc072ed8ef0.Width{id: 6805} during optimization of variable with near-zero coefficient, which should never happen.

我在添加这些约束的几个 View 中遇到了这个错误。此错误消息的一种变体如下:

Auto layout internal error. Cannot find an outgoing row head for incoming head {id: 6630} during optimization of variable with near-zero coefficient, which should never happen.

有没有人遇到过与此错误类似的问题?关于如何调试它的任何提示?

最佳答案

我仍然不是 100% 确定为什么会这样,但关键是如果您将整数作为相等宽度或高度的约束值,您将获得接近零的约束系数。

例如,您不能使用 1.2 或 0.8 等固定值,您需要使用 0.79999 或 1.199999,否则您会在某些设备上崩溃。

我更新了所有约束以使用像 0.7999 这样的数字并且它起作用了。

想要疯狂的证据吗?把它放在 Playground 上:

let a: Double = 0.8
let b: Double = 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1
print(a == b)

然后 playground 结果读起来令人震惊:

0.80.79999999“假”

疯狂,但这恰恰说明了错误发生的原因。希望这会有所帮助。

关于ios - 关闭 View 时发生自动布局内部错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34409481/

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