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
1
vote
0 answers

Xcode UIStackView Weird LayoutConstraints Issue

I am adding a MapView (bascially a UIView) inside an empty UIStackView inside an empty UIScrollView. I implemented it the following way: private func setupScrollView() { scrollView.translatesAutoresizingMaskIntoConstraints = false …
Wendell
  • 474
  • 3
  • 12
1
vote
1 answer

Stackview Show hide constraints not making self sizing possible

I've made UI for cell in cell class below: final class OptionTVCell: UITableViewCell { fileprivate static let id = String(describing: OptionTVCell.self) private var defaultTintColor: UIColor { let color =…
Amber K
  • 700
  • 1
  • 5
  • 20
1
vote
1 answer

How to add a responsive UIPageViewController inside an UIStackView programmatically?

I am trying to place an UIPageViewController inside a UIView with no predetermined height. What I am trying to achieve is build a responsive In-app Message that has one or more components (buttons, texts, carousels, etc) that has its height…
1
vote
0 answers

adjust the size of my textview in stackview and blank spaces

I have a stack view in my scroll view and there are 3 views in my stack. (arranged subviews) The second of them is a text view if my text is not long there may some blank space on my screen I guess I did some mistakes. How can I remove this space…
portable
  • 11
  • 3
1
vote
1 answer

UIStackView with custom size elements and item in the center - Swift - Programmatically

I want to set a UIStackView with 3 views to the bottom of my so that the centre view is positioned in the centre and the other views are adjusted accordingly, I want also to be able to set the width and height anchors for all 3 views. This is the…
StackGU
  • 868
  • 9
  • 22
1
vote
1 answer

Swift - Infinite Scrolling for UIScrollView with an embedded UIStackView

Someone helped with the below code to achieve what I needed to do here:- UIPageViewController - Detect scrolling halfway into the next view controller (almost working) to change button color? Whilst keeping the existing behaviour intact, I would…
Wael
  • 489
  • 6
  • 19
1
vote
1 answer

Removed element in stack views not disappearing on screen

I'm trying to create a table editor with buttons to add or remove rows and columns and I'm having an issue with the remove part. I start with a 2*2 table, made of 2 vertical stacks in a horizontal stack, filled with label A and C in the first vStack…
Prunsse
  • 51
  • 6
1
vote
0 answers

How to make dynamic UIStackView inside UITableViewCell?

I have following, completely ruined design after I tried to implement dynamic-vertical UIStackView inside UITableViewCell: As you noticed, the label on top of this card is not fitting inside cell. Basically, this cell contains following UI…
neo
  • 1,314
  • 2
  • 14
  • 34
1
vote
1 answer

How to centre-align views in a stack view, and not stretch any of the views, or the distribution?

I am building a custom longitude/latitude selector. The view looks like: textfield ° textfield ′ textfield ″ N|S The components are all in a stack view. I would like the width of the textfields to auto-fit the content. Here is the code that I am…
Sweeper
  • 213,210
  • 22
  • 193
  • 313
1
vote
2 answers

UIStackView with custom constraints - "Unable to simultaneously satisfy constraints" when changing axis

I've stumbled upon an issue with UIStackView. It has to do with the case when there are some custom constraints between the UIStackView and its arranged subviews. When changing the stack view's axis and the custom constraints, the error message…
Nikolay Suvandzhiev
  • 8,465
  • 6
  • 41
  • 47
1
vote
1 answer

Stack view within a scroll view doesn't scroll

I've been having such a hard time with this issue for the past 2 days. The structure I'm looking for is as follows: I want to have a scroll view take up the entire screen so that it's scrollable vertically. I want the image view to be added at the…
Kevvv
  • 3,655
  • 10
  • 44
  • 90
1
vote
1 answer

Why does parent UIStackView not recognize child StackView's height?

I am trying to load a UIStackView from a xib that contains multiple labels into a parent UIStackView. The labels in the child stack get populated with values (or hidden) after the ViewController in the viewDidLoad method via a model object. I expect…
Troy
  • 51
  • 7
1
vote
2 answers

UIStackView arrangedElement override alignment

I have a stackview in my iOS app with many arranged elements. For most of the elements, I want to center them vertically in my stack. However, for some elements, I want to visually tweak them by moving them a few units above or below the center…
Winston Du
  • 340
  • 2
  • 9
1
vote
1 answer

TableView Disappears from the View Hierarchy Debugger

I use xCode 11.5. If I wrap an Empty UIView and a UITableView into a stack view and the choose Fill for the distribution way, the UITableView will disappear in the Simulator interface. I've checked the View Hierarchy Debugger and the UITableView is…
marcel
  • 77
  • 1
  • 4
  • 16
1
vote
2 answers

View is using height of contained UIImageView, how do I get it to resize?

I have the following layout: There are no height constraints on any of the views. Background Image View is pinned to the top, bottom and leading edges of the container. All the vertical compression and hugging priorities are left as default. I am…
Kex
  • 8,023
  • 9
  • 56
  • 129