I am creating an app using swift. In one of my ViewController, I have a GMSMapView that I create programatically. I want user to have the capability triggering an action when clicking on the map.
What I have done :
import UIKit
class MapViewController: UIViewController, GMSMapViewDelegate {
let mapView = GMSMapView()
override func viewDidLoad() {
super.viewDidLoad()
mapView.delegate = self
mapView.settings.scrollGestures = false
mapView.frame = CGRectMake(0, 65, 375, 555)
view.addSubview(mapView)
var tap = UITapGestureRecognizer(target: self, action: "tap:")
mapView.addGestureRecognizer(tap)
}
func tap(recogniser:UITapGestureRecognizer)->Void{
println("it works")
}
}
I have tried to override touchesBegan, didnt work. I have tried to insert mapView.userInteractionEnabled = true, didnt work...
Any idea?