-2

The stack of my views is this:

superView
-scrollview = CONSTRAINTS(leading: superView, trailing: superView, top: superView, bottom: superView)
--view = CONSTRAINTS(leading: superView, trailing: superView, top: superView, bottom: superView, equalWidth: scrollView, equalHeight[priority: 250]: scrollView)
---collectionView = CONSTRAINTS(leading: view, trailing: view, top: view, height: 50)
---containerView = CONSTRAINTS(leading: view, trailing: view, top: collectionView, bottom: view)

I've search all the questions that about containerView inside scrollview but none of it solve my problem.

MMG
  • 3,226
  • 5
  • 16
  • 43
AJ Seraspi
  • 113
  • 1
  • 14
  • have you give fixed height to collectionview? – VishalPethani May 04 '20 at 07:53
  • yep collectionview has a fixed height of 50 – AJ Seraspi May 04 '20 at 07:55
  • How does it work using equalHeight[priority: 250]: scrollView. Height of view must be higher than scrollview. – Kasım Özdemir May 04 '20 at 08:15
  • These constraints don't imply scrolling. The `view` height is equal to the `scrollview` height. `collectionview` has 50 height and `containerview` takes the rest of the space. To make it scrollable the height of the `view` should be bigger than the height of the `scrollview` – Alexander Gaidukov May 04 '20 at 08:33
  • @AlexanderGaidukov yes I realized that if I set constraint height for containerView it will now scroll, but the problem is that the containerView height should not be fixed because containerView height will depend on the embedded view – AJ Seraspi May 04 '20 at 08:43

1 Answers1

1

I manage to solve this by setting the embedded view to translatesAutoresizingMaskIntoConstraints = false put it in prepareForSegue

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
 segue.destination.view.translatesAutoresizingMaskIntoConstraints = false
}

my reference: Sizing a Container View with a controller of dynamic size inside a scrollview

AJ Seraspi
  • 113
  • 1
  • 14