Auto-link internal error while deleting view

I get a ridiculous error when I reject some views on which I have some limitations.

Internal auto-layout error. Cannot find the outgoing header line for the incoming head AppName.ViewName: 0x7fc072ed8ef0.Width {id: 6805} during optimization of a variable with an almost zero coefficient, which should never happen.

I get this error in several views to which I add these restrictions. One variation of this error message is as follows:

Internal auto-layout error. Unable to find the outgoing header line for the incoming head {id: 6630} during optimization of a variable with an almost zero coefficient, which should never be.

Has anyone encountered similar issues with this error? Any tips on debugging it?

+5
source share
1 answer

I'm still not 100% sure why this is the case, but the key is that you get an almost zero coefficient under constraints if you have integers as constraint values ​​for the same width or height.

For example, you cannot do flat values, such as 1.2 or 0.8, you need to do 0.79999 or 1.199999, otherwise you will have crashes on some devices.

I updated all my restrictions to use numbers like 0.7999 and it worked.

Want proof of insanity? Put this on the 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) 

Then the playground reads amazingly:

0.8 0.79999999 False

Madness, but it shows exactly why the error occurred. Hope this helps.

+3
source

Source: https://habr.com/ru/post/1238915/


All Articles