Make keyboard disappear when clicking outside of Search Bar - SWIFT
问题 I have a UIViewController and I have embedded a Search Bar and a Collection View. When I press on the searchbar, the keyboard appears. I would like to hide this keyboard if the user decides to change his mind by tapping any where on the screen but the search bar. I have tried the following without success: Adding a Tap Gesture Recognizer using 'self.mySearchBar.endEditing(true)' class CollectionViewFolder: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate