Why would I need contraints on elements that live inside my stack view? Is not the idea of the Stack View to stack elements automatically thus making the need of explicit measures to be added?
Asked
Active
Viewed 755 times
1 Answers
4
Well Said. Stackview
get its height and width from content size
.
Sometime we cannot say exactly how much content size
a ui element
has.
For example if we have an imageview
inside stackview
and we assign image
at runtime. The stackview
will grow with the imageview
. The question is how much. Well it depends on the size of image. So there we can feel undesired results. So we fix stackview
size using predefined constraints
.
Also, Stackview
need constraints
for position. Where to position stackview
inside view of viewcontroller
. So we need constraints
for positioning our stackview
.

Irfan
- 5,070
- 1
- 28
- 32
-
Thanks, that makes sense for horizontal rules but How about height for vertical stack views? XCode is nagging me that I need a height but I really don't know how long it will be or I don't really care. I can wrap the content on a Scroll View but the height of the Stack View should be ignored. – Helmut Granda Mar 10 '16 at 05:20
-
As @Irfan say `Stackview get its height and width from content size.` this sentence is the key. – Ricardo Dec 02 '16 at 13:26