Date
1 - 1 of 1
TextFields in a Row with AutoLayout
Gerriet M. Denkmann
macOS 12.6, Xcode Version 9.1 (9B55).
A window with:
fixedSpace | fixedTextField | fixedSpace | textField(width ≥ 50) | fixedSpace | textField(width ≥ 100) | variableSpace( width ≥ 10)
This implies window.width ≥ sumOfFixedStuff + 50 + 100 + 10.
At the minimum window size both contents of the variable textFields are truncated (assuming big contents).
When the window grows, the textField(width ≥ 50) will expand first (as it is more adverse to having its content squashed with Content Compression Resistance Priority = 751) until it can show all of its content.
When the window grows even more, the textField(width ≥ 100) will eventually also show all its content.
From here on, only the variableSpace( width ≥ 10) will grow.
I don’t see any ambiguity here - but sadly, Xcode does (Inequality Constraint Ambiguity width ≥ 100).
When I run the program, I see variableSpace having its minimum width and textField(width ≥ 100) taking all of the available width, which looks very silly.
I can fix this by changing to textField(width = 50) and textField(width = 100), but then I get the (quite correct warning) that this might result in truncation at runtime.
How to make Xcode behave as I want?
Gerriet.
A window with:
fixedSpace | fixedTextField | fixedSpace | textField(width ≥ 50) | fixedSpace | textField(width ≥ 100) | variableSpace( width ≥ 10)
This implies window.width ≥ sumOfFixedStuff + 50 + 100 + 10.
At the minimum window size both contents of the variable textFields are truncated (assuming big contents).
When the window grows, the textField(width ≥ 50) will expand first (as it is more adverse to having its content squashed with Content Compression Resistance Priority = 751) until it can show all of its content.
When the window grows even more, the textField(width ≥ 100) will eventually also show all its content.
From here on, only the variableSpace( width ≥ 10) will grow.
I don’t see any ambiguity here - but sadly, Xcode does (Inequality Constraint Ambiguity width ≥ 100).
When I run the program, I see variableSpace having its minimum width and textField(width ≥ 100) taking all of the available width, which looks very silly.
I can fix this by changing to textField(width = 50) and textField(width = 100), but then I get the (quite correct warning) that this might result in truncation at runtime.
How to make Xcode behave as I want?
Gerriet.