你好,我正在這個應用程序,所以我可以在PinView內按下按鈕,它會加載彈出視圖。我很困惑如何讓這個工作,因爲我認爲我需要把它作爲一個IBAction,但我不認爲我可以這樣做,因爲它隱藏在main.storyboard中。如何在PinView中打開UIButton打開彈出式視圖?
extension ViewController : MKMapViewDelegate {
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView?{
if annotation is MKUserLocation {
//return nil so map view draws "blue dot" for standard user location
return nil
}
let reuseId = "pin"
var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? MKPinAnnotationView
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
pinView?.pinTintColor = UIColor(red: 52/255.0, green: 73/255.0, blue: 94/255.0, alpha: 1.0)
pinView?.canShowCallout = true
let removeButton = UIButton(type: .Custom)
removeButton.frame = CGRect(x: 0, y: 0, width: 40, height: 40)
removeButton.setImage(UIImage(named: "RadiusSettings")!, forState: .Normal)
pinView?.leftCalloutAccessoryView = removeButton
return pinView
}
}
任何幫助,將不勝感激,謝謝