视图关闭时发生自动布局内部错误 [英] Auto layout internal error happening when a view is dismissed
问题描述
自动布局内部错误。
当我忽略某些视图时,我遇到一个有趣的错误。在
的
优化变量的接近零的系数,这应该
永远不会发生,找不到一个输出行头
传入头AppName.ViewName:0x7fc072ed8ef0.Width {id:6805} p>
我在添加这些约束的几个视图中收到此错误。此错误消息的一个变体如下:
自动布局内部错误。
在
变量接近零的系数优化期间找不到传入头{id:6630}的传出行头,这应该永远不会发生。
有没有人遇到类似的问题与此错误?关于如何调试它的任何提示?
我仍然不能100%确定为什么是这样,关键是如果你有整数作为等宽或高度的约束值,你就会在约束上得到接近于零的系数。
例如你不能做平面值如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)
$ b
疯狂,但这显示了为什么bug发生。希望这有助于。
I'm getting a funny error when I dismiss some views on which I have some constraints.
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.
I'm getting this bug on several views to which I'm adding these constraints. One variation of this error message is the following:
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.
Has anyone experienced similar issues with this error? Any tips on how to debug it?
I'm still not 100% sure why this is the way it is, but the key is that you get near-zero coefficient on constraints if you have whole numbers as the constraint values for equal width or height.
For example you can't do flat values like 1.2, or 0.8, you need to do 0.79999 or 1.199999 or you will have crashes on some devices.
I updated all my constraints to use numbers like 0.7999 and it worked.
Want proof of the craziness? Put this in a 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)
The playground results then read astoundingly:
0.8 0.79999999 "false"
Craziness, but this shows exactly why the bug was happening. Hope this helps.
这篇关于视图关闭时发生自动布局内部错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!