title: Adding accessory button on user location callout
body: <p>I'm making a clickable placemark. I set the title of the placemark. Title is adress. I want If you click on that adress It will push to another View to Show Adress Number,City,Country etc. I Tried this code. But It haven't UIButton in application in placemark, why? </p>
  
  <p><strong>EDIT:</strong> If I put breakpoint to func  calloutAccessoryControlTapped it isn't crashing.</p>
  
  <pre><code>func mapView(Mapa: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -&gt; MKAnnotationView! {
  
      if annotation is MKUserLocation {
          //return nil so map view draws "blue dot" for standard user location
          return nil
      }
  
      var pin = "pin"
  
      var view = Mapa.dequeueReusableAnnotationViewWithIdentifier(pin) as? MKPinAnnotationView
      if view == nil {
          view = MKPinAnnotationView(annotation: annotation, reuseIdentifier: pin)
          view!.canShowCallout = true
          view!.animatesDrop = true
          var arrowButton = UIButton()
          view!.rightCalloutAccessoryView = UIButton.buttonWithType(.DetailDisclosure) as! UIButton
      } else {
          view!.annotation = annotation
      }
      return view
  }
  
  func mapView(Mapa: MKMapView!, annotation: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
  
      if control == annotation.rightCalloutAccessoryView {
          println("Pressed!")
      }
  }
  </code></pre>
  
  <p>Whole code: </p>
  
  <pre><code>import UIKit
  import CoreLocation
  import MapKit
  
  class ViewController: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate {
  
      @IBOutlet weak var Mapa: MKMapView!
      let locationManager = CLLocationManager()
      var detail: UIButton!
  
      override func viewDidLoad()
      {
          super.viewDidLoad()
  
  
          locationManager.delegate = self
          locationManager.desiredAccuracy = kCLLocationAccuracyBest
          locationManager.requestAlwaysAuthorization()
          locationManager.startUpdatingLocation()
  
  
  
          Mapa.delegate = self
          Mapa.mapType = MKMapType.Standard
          Mapa.showsUserLocation = true
  
  
      }
  
      override func didReceiveMemoryWarning()
      {
          super.didReceiveMemoryWarning()
  
      }
  
  
  
      //--- Find Address of Current Location ---//
  
      func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!)
      {
          //--- CLGeocode to get address of current location ---//
          CLGeocoder().reverseGeocodeLocation(manager.location, completionHandler: {(placemarks, error)-&gt;Void in
              let spanX = 0.007
              let spanY = 0.007
              var newRegion = MKCoordinateRegion(center: self.Mapa.userLocation.coordinate, span: MKCoordinateSpanMake(spanX, spanY))
              self.Mapa.setRegion(newRegion, animated: true)
  
  
              if (error != nil)
              {
                  println("Reverse geocoder failed with error" + error.localizedDescription)
                  return
              }
  
              if placemarks.count &gt; 0
              {
                  let pm = placemarks[0] as! CLPlacemark
                  self.displayLocationInfo(pm)
              }
              else
              {
                  println("Problem with the data received from geocoder")
              }
          })
  
      }
  
  
      func displayLocationInfo(placemark: CLPlacemark?)
      {
          if let Placemark = placemark
          {
              //Stop updating kvôli vydrži baterke
              locationManager.stopUpdatingLocation()
              let location = self.locationManager.location
              var latitude: Double = location.coordinate.latitude
              var longitude: Double = location.coordinate.longitude
              let adresa = (Placemark.thoroughfare != nil) ? Placemark.thoroughfare : "Ulica: "
              let cislo = (Placemark.subThoroughfare != nil) ? Placemark.subThoroughfare : "Číslo ulice:"
              let mesto = (Placemark.locality != nil) ? Placemark.locality : "Mesto: "
              let stat = (Placemark.country != nil) ? Placemark.country : "Štát: "
  
  
  
  
              var coordinates:CLLocationCoordinate2D = placemark!.location.coordinate
              let theLocation: MKUserLocation = Mapa.userLocation
              theLocation.title = adresa
  
  
  
  
              println("GPS Súradnice :: \(latitude), \(longitude)")
              println(mesto)
              println(adresa)
              println(cislo)
              println(stat)
  
          }
  
      }
  
      func locationManager(manager: CLLocationManager!, didFailWithError error: NSError!)
      {
          println("Chyba pri aktualizovaní lokácie " + error.localizedDescription)
      }
  
      func mapView(Mapa: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -&gt; MKAnnotationView! {
  
          if annotation is MKUserLocation {
              //return nil so map view draws "blue dot" for standard user location
              return nil
          }
  
          var pin = "pin"
  
          var view = Mapa.dequeueReusableAnnotationViewWithIdentifier(pin) as? MKPinAnnotationView
          if view == nil {
              view = MKPinAnnotationView(annotation: annotation, reuseIdentifier: pin)
              view!.canShowCallout = true
              view!.animatesDrop = true
              var arrowButton = UIButton()
              view!.rightCalloutAccessoryView = UIButton.buttonWithType(.DetailDisclosure) as! UIButton
          } else {
              view!.annotation = annotation
          }
          return view
      }
  
      func mapView(Mapa: MKMapView!, annotation: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
  
          if control == annotation.rightCalloutAccessoryView {
              println("Pressed!")
          }
      }
  }
  </code></pre>