1

I have a popover (alert) as a custom view (UIViewController). As subviews, in storyboard, I have a stack view with some labels and I added a scroll view as superview for stack view. In portrait mode it shows fine, but when moving to landscape I don't know what I have to do to make the stack view scrollable. I tried a lot of approaches: to make the stack view smaller, or to make the scroll view smaller or to embed another content view so the scrolls appears, but it doesn't work. How to make a stack view scrollable when going from portrait to landscape?

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransition(to: size, with: coordinator)
    coordinator.animate(alongsideTransition: nil) { _ in
        if self.device.isPhone {
            let isOrientationLandscape = self.device.orientation == .horizontal
            if isOrientationLandscape {
                self.scrollView.translatesAutoresizingMaskIntoConstraints = false
                self.contentView.translatesAutoresizingMaskIntoConstraints = false 
                self.contentView.heightAnchor.constraint(equalToConstant: 125.0).isActive = true
                self.scrollView.contentSize = CGSize(width: self.scrollView.frame.size.width, height: self.contentView.frame.size.height)
          }
     }
}

I need to look something like this

Claudiu
  • 41
  • 6
  • Have you looked at [this](https://stackoverflow.com/questions/31668970/is-it-possible-for-uistackview-to-scroll#35136217) question? – Dennis W. Feb 02 '19 at 02:40
  • This [blog post](https://blog.alltheflow.com/scrollable-uistackview/) might help as well. – Dennis W. Feb 02 '19 at 02:48

0 Answers0