你好,我正在这个应用程序,所以我可以在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
}
}
任何帮助,将不胜感激,谢谢