title: Dismiss the Keyboard in Swift via hitTest
body: <p>My code inside a UIView Class that contains a UITextField named titleInput:</p>
  <pre><code>override func hitTest(point: CGPoint, withEvent event: UIEvent?) -&gt; UIView? {
      // Code to Dismiss the Keyboard when Pressed Outside Text Field
      if !titleInput.pointInside(point, withEvent: event) {
          endEditing(true)
      }
      
      // Return Original hitTest Result as Usual
      return super.hitTest(point, withEvent: event)
  }
  </code></pre>
  <p>I am experiencing a strange bug. When I first start the app, everything works as expected, touching outside the titleInput dismisses the keyboard. However, it brakes if I switch to a different app, and than come back to this app. After coming back to the app, clicking on the keyboard also dismisses the keyboard. Makes it difficult to type :)</p>
  <p>Any idea why this is happening, and why it ONLY starts to happen after switching away from the app and then coming back to it? Also, is there a better way to do this same thing.</p>