title: ScrollView inside StackView
body: <p>I created vertical stackView:
  <a href="https://i.stack.imgur.com/g6icZ.png" rel="nofollow noreferrer">screenshot</a></p>
  
  <p>And add scrollView inside it:</p>
  
  <pre><code>let scrollView = UIScrollView()
  scrollView.translatesAutoresizingMaskIntoConstraints = false
  scrollView.contentMode = .scaleToFill
  scrollView.clipsToBounds = true
  self.addArrangedSubview(scrollView)
  scrollView.leftAnchor.constraint(equalTo: self.leftAnchor, constant: 0).isActive = true
  scrollView.topAnchor.constraint(equalTo: label.bottomAnchor, constant: 0).isActive = true
  scrollView.rightAnchor.constraint(equalTo: self.rightAnchor, constant: 0).isActive = true
  scrollView.heightAnchor.constraint(equalToConstant: 100).isActive = true
  </code></pre>
  
  <p>Inside this scrollView i added horizontal scrollView:</p>
  
  <pre><code>let imageStack = UIStackView()
  imageStack.spacing = 5
  imageStack.axis = .horizontal
  imageStack.alignment = .center
  imageStack.contentMode = .left
  imageStack.distribution = .fillProportionally
  imageStack.translatesAutoresizingMaskIntoConstraints = false
  scrollView.addSubview(imageStack)
  imageStack.heightAnchor.constraint(equalToConstant: 100).isActive = true
  imageStack.topAnchor.constraint(equalTo: scrollView.topAnchor, constant: 0).isActive = true
  imageStack.leftAnchor.constraint(equalTo: scrollView.leftAnchor, constant: 0).isActive = true
  imageStack.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor, constant: 0).isActive = true
  imageStack.rightAnchor.constraint(equalTo: scrollView.rightAnchor, constant: 0).isActive = true
  </code></pre>
  
  <p>in this imageStack i programmatically insert images. But when there are many images (more than 4) they are superimposed on each other and scroll is not working. </p>
  
  <p>is it possible to use horizontal scroll for arranged subview inside vertical stackView?  or it is impossible to do width of subview more than vertical stackView width?</p>
  
  <p><strong>EDITED</strong></p>
  
  <p>i tried to edit constraints such as @beyowulf recommend, but nothing changed. Look at the <a href="https://i.stack.imgur.com/zW7He.png" rel="nofollow noreferrer">screenshot</a>. I added 5 images to imageStack, but visible only part if them and scroll isn`t working</p>
  
  <p><strong>EDITED</strong>
  look at code where i find imageStack and add images into it:</p>
  
  <pre><code>let scrollView = self.dynamicView.subviews.first(where: {$0 is UIScrollView}) as! UIScrollView
  let filesView = scrollView.subviews.first(where: { $0 is UIStackView } ) as! UIStackView
  var filesCount = filesView.arrangedSubviews.count - 1
  
  for image in images {
      let imgView = UIImageView()
      imgView.translatesAutoresizingMaskIntoConstraints = false
      let imageViewWidthConstraint = NSLayoutConstraint(item: imgView, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 100)
      let imageViewHeightConstraint = NSLayoutConstraint(item: imgView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 100)
      imgView.addConstraints([imageViewWidthConstraint, imageViewHeightConstraint])
      imgView.contentMode = .scaleAspectFill
      imgView.clipsToBounds = true
      imgView.image = image
      imgView.isUserInteractionEnabled = true
      let swipeToTopRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(imageDelete))
      swipeToTopRecognizer.direction = .up
      let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(imageTapped))
      imgView.addGestureRecognizer(tapRecognizer)
      imgView.addGestureRecognizer(swipeToTopRecognizer)
      filesView.insertArrangedSubview(imgView, at: filesCount)
      filesCount += 1
  }
  </code></pre>