-2

I have custom XIB's which I will be using to create my ViewController at runtime. Which all XIB's are to be included inside the ViewController will be decided at runtime.

I am using a stackView for that purpose which I have added to the storyboard and constrained it to leading-triling-top-bottom of the superView. That means the stackView will be stretched to the height of the viewController.

Now when i have few Custom Views(or XIB), say 3, it should not cover the complete screen but rather stick to it's size and be added to the stackView

But my problem arises here: Since I have constrained the stackView to complete screen(as sometimes the number of XIB can be a lot more and will surpass the size of the screen and hence I might need a scrollable stackView), it shows like this

enter image description here

I have found kind of a hack here but I don't think that's gonna cut

StackView's Alignment - Fill, Distribution - Equal Spacing (0)

Community
  • 1
  • 1
user121095
  • 697
  • 2
  • 6
  • 18

2 Answers2

0

step 1. make the bottom constraint between super view and your stack view as Equal or more

step 2. make the height constraint to your stack view with priority 1 and constant 0

step 3. ensure you views inside stack view layouts correctly - all edges should be installed in each views

Davydov Denis
  • 346
  • 1
  • 6
0

I solved it by :

  1. Removing the bottom constraint of the stackView
  2. Changing the Intrinsic size under Size Inspector from System Defined to Placeholder and setting the height to 1
user121095
  • 697
  • 2
  • 6
  • 18