I have been trying to make the keyboard dismiss when I touch off the keyboard. I found one piece of code that seems to work (kind of), but it only works if I am not touching any other kind of view. By this I mean, I have a scroll view that takes up the majority of the screen. If I tap off the scroll view it will disappear, but if I tap anywhere on the scroll view, nothing happens. This is the code segment I am using. Any help would be much appreciated.
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(true)
}