Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is this Stack View layout ambiguous?

I'm trying to create a relatively simple (!) layout with iOS 9 Stack Views. This is the Storyboard:

enter image description here

With the following layout:

enter image description here

But it's ambiguous: Titles Stack View: Need constraints for: X position or width, Times Stack View: Need constraints for: X position or width. I don't understand why. I've set the horizontal content hugging priority of the Titles Stack View to less than that of the Times Stack View, what else do I need to do?

like image 319
Robert Atkins Avatar asked Feb 11 '16 15:02

Robert Atkins


People also ask

What causes a layout to be considered ambiguous?

Ambiguous layouts occur when the system of constraints has two or more valid solutions. There are two main causes: The layout needs additional constraints to uniquely specify the position and location of every view.

How do I use stack view auto layout?

Views and Constraints Begin by laying out the name rows in Interface Builder. Position the label and text field in their correct relative positions, select them both, and then click the Editor > Embed In > Stack View menu item. This creates a horizontal stack view for the row.

What is stack view in IOS Swift?

Stack views let you leverage the power of Auto Layout, creating user interfaces that can dynamically adapt to the device's orientation, screen size, and any changes in the available space. The stack view manages the layout of all the views in its arrangedSubviews property.

When would you use a stack view?

Best use of stack view is that if you want to set multiple controls allinged vertically or horizontally to each other you just add all of them in stack view. stackview will handle its allignment you just need to give frame contraints to stackView.


1 Answers

My Times Stack View alignment was set to Trailing, setting it to Fill fixed the problem.

(Though Xcode shows some of the views misplaced no matter what I do, but I'm putting this down as a bug)

like image 142
Robert Atkins Avatar answered Sep 24 '22 07:09

Robert Atkins