title: Custom Callout View Button to Map
body: <p>I am working on a MapView where on click of any custom annotation pin, I am showing custom callout view (load from xib file).</p>
  
  <p>From this Custom Callout I have an UIButton, I already can detect click on this button but I want to access on the Map like the : view?.rightCalloutAccessoryView in the basic callout.</p>
  
  <pre><code>func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView,  {
  
      if view.annotation!.isKind(of: MKUserLocation.self){
          return
      }
  
      let customView = (Bundle.main.loadNibNamed("CustomCalloutView", owner: self, options: nil))?[0] as! CustomCalloutView;
      let calloutViewFrame = customView.frame;
      customView.frame = CGRect(x: -calloutViewFrame.size.width/2.23, y: -calloutViewFrame.size.height+10, width: 315, height: 170)
  
      view.addSubview(customView)
  
      let region = MKCoordinateRegion(center: pinToZoomOn!.coordinate, span: span)
  
      mapView.setRegion(region, animated: true)
  }
  </code></pre>
  
  <p>The route is correctly calculated from the classic callout but I can't know how to access my map from the button of my custom callout.</p>
  
  <p>My CustomCalloutViewClass :</p>
  
  <pre><code>import UIKit
  import MapKit
  
  class CustomCalloutView: MKAnnotationView {
  
  @IBOutlet weak var goButton: UIButton!
  
  @IBAction func goButton(_ sender: AnyObject) {
      print("Button clicked sucessfully")
  }
  
  // MARK: - Detect taps on callout
  
  override func hitTest(_ point: CGPoint, with event: UIEvent?) -&gt; UIView? {
      let hitView = super.hitTest(point, with: event)
      if hitView != nil {
          superview?.bringSubview(toFront: self)
      }
      return hitView
  }
  
  override func point(inside point: CGPoint, with event: UIEvent?) -&gt; Bool {
      let rect = self.bounds
      var isInside = rect.contains(point)
      if !isInside {
          for view in subviews {
              isInside = view.frame.contains(point)
              if isInside {
                  break
              }
          }
      }
      return isInside
  }
  }
  </code></pre>
  
  <p>If someone have an idea it will be helpfull I'm stuck on this issue.</p>
  
  <p>Thank you in advance.</p>