title: Swift, how to convert an existing uiview to uiscrollview?
body: <p>I have a storyboard with just one view at the moment but i needed to add 5 more textfields. So i like to enable the vertical scroll. I thought i just had to change the class of the viewcontroller from UIView to UIScrollView:</p>
  
  <p><a href="https://i.stack.imgur.com/0wijg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0wijg.png" alt="enter image description here"></a></p>
  
  <p>Besides changes the class what else should i do so i can enable vertical scroll for this view??
  Only thing i have in viewDidLoad()</p>
  
  <pre><code>    override func viewDidLoad() {
      super.viewDidLoad()
      // Do any additional setup after loading the view, typically from a nib.
  
      // Set date to today
      let today = dateToday()
      dateInvoice.text = today
  }
  </code></pre>
  
  <p>edit
  ok i got the scrolling part working, but the hide/dismiss keyboard part doesn't work anymore. How do i dismiss the keyboard if a user clicks outside a textfield in scrollview</p>
  
  <pre><code>    //HIDE KEYBOARD
  func textFieldShouldReturn(textField: UITextField) -&gt; Bool {
      textField.resignFirstResponder()
      return true
  }
  override func touchesBegan(touches: Set&lt;UITouch&gt;, withEvent event: UIEvent?) {
      self.view.endEditing(true)
  }
  //END HIDE KEYBOARD
  </code></pre>
  
  <p>Edit 2:
  I found a workable solution thanks to:
  <a href="https://stackoverflow.com/questions/30434467/swift-uiscrollview-keyboard-doesnt-dismiss-interactively">Swift UIScrollView : keyboard doesn&#39;t dismiss interactively</a></p>
  
  <p><a href="https://i.stack.imgur.com/VFPr4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VFPr4.png" alt="enter image description here"></a></p>