How to make UIView which is inside scrollview adapt to screen orientation when user changes screen from portrait to landscape in swift?

```
var scrollView: UIScrollView = {
    var scroll = UIScrollView()
    scroll.translatesAutoresizingMaskIntoConstraints = false

    return scroll
}()

view.addSubview(scrollView)

scrollView.topAnchor.constraint(equalTo: view.topAnchor, constant: 100).isActive = true
scrollView.centerXAnchor.constraint(equalTo: view.centerXAnchor, constant: 0).isActive = true
scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true
scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0).isActive = true
scrollView.heightAnchor.constraint(equalToConstant: 500).isActive = true

for i in 0..<arr.count {
    var contentView = UIView()
    contentView.frame = CGRect(x: i * Int(view.bounds.size.width) + 10, y: 0, width: Int(view.bounds.size.width) - 20 , height: Int(view.frame.height))

    scrollView.contentSize = CGSize(width: (view.frame.size.width * CGFloat((Double(i)+1))) ,height: scrollView.frame.size.height) 
}

```

[Image](https://i.stack.imgur.com/8Bt4Z.png)