I want to override the default behavior of double tapping the mapView.
In my swift
app I have a mapView
in a static cell, so in the method cellForRowAt
I've decided to add a UITapGestureRecognizer
. This is how I do it:
func tableView(_ myTable: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if (indexPath as NSIndexPath).row == 0 {
let cell = myTable.dequeueReusableCell(withIdentifier: "cellStatic") as! MyTableDetailsCell
cell.mapView.isScrollEnabled = false //this works
//this does not:
let tap = UITapGestureRecognizer(target: self, action: #selector(doubleTapped))
tap.numberOfTapsRequired = 2
cell.mapView.addGestureRecognizer(tap)
...
And then I have a simple function:
func doubleTapped() {
print("map tapped twice")
}
But when I tap twice the map - it zooms in and there's no print in the console log - so my code doesn't work. What did I miss?