How do I detect a single tap on an instance of MKMapView
? Do I have to subclass MKMapView
and then override the touchesEnded
method?>
my 2 cents for swit 5.x:
override func touchesEnded(_ touches: Set, with event: UIEvent?) {
if let touch = touches.first {
let v = touch.view
let ssv = v?.superview?.superview
if ssv === self.mapView{
searchBar.resignFirstResponder()
}
}
}
it works. but honestly can break if apple changes layers of views. better a recognizer.