title: Swift - After loading subview from xib to UIScrollView, scroll is not working and subview is going out of bounds
body: <p>I have the following scenario:</p>
  
  <ol>
  <li>I have a xib file of name View1.xib which contain some stack views containing certain set of buttons.</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/IcMf3.png" rel="nofollow noreferrer">View1.xib UIView</a></p>
  
  <ol start="2">
  <li><p>Im having a coco touch class of type UIView for loading the Nib named View1. Also I have made it as owner of the previous xib. Below is the code I'm using to load the view:</p>
  
  <pre><code>override init(frame: CGRect) {
      super.init(frame: frame)
      commitInit()
  }
  
  required init?(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)
      commitInit()
  }
  
  private func commitInit() {
      Bundle.main.loadNibNamed("View1", owner: self, options: nil)
  
      containerView.frame = self.bounds
      containerView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
      addSubview(containerView)
  }
  </code></pre></li>
  <li><p>Now in the storyboard I included the scrollview and a sub UIView under it. I have defined the Subview type as View1.</p></li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/WJIpH.png" rel="nofollow noreferrer">ScrollView in main storyboard</a></p>
  
  <ol start="4">
  <li>Also I have defined proper constraints for the Views making it equal height and width as the Parent ScrollView.</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/lZp15.png" rel="nofollow noreferrer">Scrollview constraints</a></p>
  
  <ol start="5">
  <li>Also find the scrollview properties defined as below: </li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/kBZq0.png" rel="nofollow noreferrer">ScrollView Properties</a></p>
  
  <ol start="6">
  <li>This is how the screen looks like on emulator :</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/ksKu5.png" rel="nofollow noreferrer">Emulator</a></p>
  
  <p>Now when I'm running the project I'm getting the screen but I'm unable to scroll through the view included. Due to this some elements on top and bottom becomes hidden (Out of bounds) and I'm unable to scroll as well. Am I  doing anything wrong? Please help me out.</p>
  
  <p>Note - I'm very new to swift, any help is greatly appreciated. Thanks in advance.</p>