关闭视图时发生自动布局内部错误
Auto layout internal error happening when a view is dismissed
当我忽略一些我有一些限制的观点时,我遇到了一个有趣的错误。
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.
我在添加这些约束的几个视图中遇到了这个错误。此错误消息的一种变体如下:
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% 确定为什么会这样,但关键是,如果您将整数作为相等宽度或高度的约束值,您将获得约束的 near-zero 系数.
例如,您不能使用 1.2 或 0.8 等固定值,您需要使用 0.79999 或 1.199999,否则您会在某些设备上崩溃。
我更新了我的所有约束以使用像 0.7999 这样的数字并且它起作用了。
想要疯狂的证据吗?把这个放在操场上:
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)
操场上的结果令人震惊:
0.8
0.79999999
"false"
疯狂,但这恰恰说明了错误发生的原因。希望这有帮助。
当我忽略一些我有一些限制的观点时,我遇到了一个有趣的错误。
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.
我在添加这些约束的几个视图中遇到了这个错误。此错误消息的一种变体如下:
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% 确定为什么会这样,但关键是,如果您将整数作为相等宽度或高度的约束值,您将获得约束的 near-zero 系数.
例如,您不能使用 1.2 或 0.8 等固定值,您需要使用 0.79999 或 1.199999,否则您会在某些设备上崩溃。
我更新了我的所有约束以使用像 0.7999 这样的数字并且它起作用了。
想要疯狂的证据吗?把这个放在操场上:
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)
操场上的结果令人震惊:
0.8 0.79999999 "false"
疯狂,但这恰恰说明了错误发生的原因。希望这有帮助。