There is an object called "imageView", I need to call the function "clicouCrosshair" always when the "imageView" is clicked, but it's not working. I've tryed some different tutorials that I found on internet but no success. Anyone know why and how can I solve this?
I think the problem is because i'm using my view as a GMSMapView.. Inside the "prepareMap" function the "UIImageView" is configured.
import UIKit
import GoogleMaps
class Maps_criarArea: UIViewController {
var projNome:String!;
var mapView:GMSMapView!;
var imageView:UIImageView!;
func clicouCrosshair(sender: AnyObject){
print("CROSSHAIR");
}
override func viewDidLoad() {
super.viewDidLoad();
GMSServices.provideAPIKey("AIzaSyB62KDZSGfbbN1IIVnlhewi4PpEZmxPJYM");
let centerBR_lat = -15.30;
let centerBR_lng = -49.57;
let cameraP = GMSCameraPosition.cameraWithLatitude(centerBR_lat, longitude: centerBR_lng, zoom: 4);
mapView = GMSMapView.mapWithFrame( CGRectZero, camera: cameraP)
mapView.myLocationEnabled = true
view = mapView;
self.prepareMap();
}
func prepareMap(){
let imageName = "crosshair";
let image = UIImage(named: imageName);
imageView = UIImageView(image: image!);
let screenSize: CGRect = UIScreen.mainScreen().bounds;
let WidthPosition = (screenSize.width*0.5)-32;
let heightPosition = (screenSize.height*0.5)-32;
imageView.frame = CGRect(x: WidthPosition, y: heightPosition, width: 64, height: 64);
imageView.userInteractionEnabled = true;
let detectTap = UITapGestureRecognizer(target: self, action: #selector(self.clicouCrosshair(_:)) )
//detectTap.numberOfTapsRequired = 1
imageView.addGestureRecognizer(detectTap)
mapView.addSubview(imageView);
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
//returning to view
override func viewWillAppear(animated: Bool) {
let saveBtn : UIBarButtonItem = UIBarButtonItem(title: "Salvar", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(Maps_criarArea.salvar(_:)) )
self.navigationItem.rightBarButtonItem = saveBtn
}
func salvar(sender:UIBarButtonItem){
}
}