Questions tagged [uistackview]

The UIStackView class provides a streamlined interface for laying out a collection of views in either a column or a row. 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 UIStackView class provides a streamlined interface for laying out a collection of views in either a column or a row. 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. These views are arranged along the stack view’s axis, based on their order in the arrangedSubviews array. The exact layout varies depending on the stack view’s axis, distribution, alignment, spacing, and other properties.

enter image description here

To use a stack view, open the Storyboard you wish to edit. Drag either a Horizontal Stack View or a Vertical Stack View out from the Object library, and position the stack view where desired. Next, drag out the stack’s content, dropping the view or control into the stack. You can continue to add views and controls to your stack, as needed. Interface Builder resizes the stack based on its content. You can also adjust the appearance of the stack’s content by modifying the Stack View’s properties in the Attributes inspector.

1429 questions
4
votes
1 answer

UIStackView inside UIScrollView: how to center-align stack view / items?

I have a UIStackView inside a UIScrollView, and when the width of all items in stack view is less then the width of the scroll view, I want to make the stack view (or the items) to be horizontally centered aligned with the scroll view. I have the…
Heuristic
  • 5,087
  • 9
  • 54
  • 94
4
votes
2 answers

How to arrange UIStackViews?

I'm starting a new project that supports iOS9 upwards and after looking at Apple's constraint guidelines they appear to suggest using StackViews whenever possible. After reading a few articles and the apple documentation I've a basic understanding…
Declan McKenna
  • 4,321
  • 6
  • 54
  • 72
4
votes
5 answers

One of the subviews of a stack view not showing up at all

I want my stack view to have three views: red image, blue image and register view. The thing is that while the red and blue button appear just fine, the register view does not. This is how I set up and place my stack view inside my view controller…
Cesare
  • 9,139
  • 16
  • 78
  • 130
4
votes
1 answer

Auto Layout on UIStackView with UIImageView inside - iOS Swift

I have some issues with auto layout when building view programmatically. There is a vertical UIStackView with several elements inside, mainly labels and images. After setting properties on stackView and imageView, as a result I get something similar…
Bastek
  • 899
  • 1
  • 12
  • 27
4
votes
1 answer

UIStackView adjust height to subviews

I want the UIStackView to resize to fit their subviews (UIImageView and UILabel in this case) let headerView = UIStackView() headerView.axis = .vertical headerView.alignment = .center headerView.distribution = .equalSpacing …
dkoch
  • 474
  • 1
  • 3
  • 15
4
votes
1 answer

Adding dynamically ViewControllers inside StackView - UIStackView inside UIScrollView

I would like to add dynamically View Controllers inside a UIStackView. The UIStackView must be scrollable so I added it inside a UIScrollView. I have an UI error, the content size is ambiguous, I tried to debug using Debug View Hierarchy and here…
Kevin Machado
  • 4,141
  • 3
  • 29
  • 54
4
votes
0 answers

I cannot change the size dimensions of StackView

Simple. I have a StackView in Storyboard and width and height are greyed out. I cannot change the size. Nor can I change the frames of any of its arrangedSubviews. Their size properties of greyed out as well. Why is this?
Alex Bollbach
  • 4,370
  • 9
  • 32
  • 80
4
votes
0 answers

Misplaced Views in Interface Builder with UIStackView

I'm using UIStackViews in Interface Builder and I keep getting caution warnings because of Misplaced Views. Going to Resolve Auto Layout Issues and selecting Updating Frames in All Views doesn't work either. It throws my entire views way out of…
dispatchswift
  • 1,046
  • 9
  • 21
4
votes
1 answer

UIStackView Spacing - Don't push to top and bottom anchors

I am trying to distribute some nested stack views and I think I'm missing a property to help me align the various views the way I want them. Here's the current output: The issue with this is that the two arranged subviews that are added to each…
Alex
  • 5,298
  • 4
  • 29
  • 34
4
votes
1 answer

Xcode stack views causing crash?

If I try to nest more than two stack views in one stack view Interface Builder slows to a crawl and I get a message saying an internal error has occurred and editing functionality may be limited. Is there a workaround for this? I've tried…
Mark
  • 171
  • 10
4
votes
2 answers

XCode: Is it possible to create reusable stack views?

Is it possible to create reusable stack views on the story board that can be used dynamically to be generated at a later time? Sort of a template/widget/component. I am aware that I can do this with a class but if I am able to visually generate a…
Helmut Granda
  • 4,565
  • 7
  • 35
  • 51
4
votes
2 answers

Adding padding to the beginning and end of a UIStackView

I've been switching over to UIStackView recently and trying to do all my layout with it and it's so much easier than using Auto Layout... with one exception. I have a layout using nested UIStackViews with a vertical stack view and inside it is a…
Fogmeister
  • 76,236
  • 42
  • 207
  • 306
4
votes
2 answers

UICollectionView: dynamic cell heights with UIStackView

I have a storyboard, consisting of a single UICollectionView with multiple cells, each of varying height. The first cell takes the height from the UICollectionViewDelegateFlowLayout: func collectionView(collectionView: UICollectionView, …
coco
  • 2,998
  • 1
  • 35
  • 58
4
votes
0 answers

UIStackView does not resize after unhiding

Am new to stack views but am trying to hide and unhide a block of nested subviews from a button in a parallel stack view. Hiding works (the targeted stack view shrinks down to one line and goes away) but when I try to unhide, the nested stack view…
drw
  • 943
  • 1
  • 10
  • 25
4
votes
2 answers

dynamic UIStackView inside of UIScrollView

Due to the extensive updates since iOS7, I wanted to ask this question because of my limited experience with autolayout and the new stackview, and I am wondering what is the best design practice to implement the following in Objective-C (not swift…
stackOverFlew
  • 1,479
  • 2
  • 31
  • 58