1
使用下面的代碼,我改變了我的圖釘外觀並從firebase下載了一張圖片。Swift Firebase在地圖註釋上下載註釋圖片點擊
問題是,我需要圖像下載時只有一個針被按下,現在,而不是這一次全部。
有人能告訴我如何檢測按下的引腳並只下載他的圖像?
我是新來的編程...
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
if !(annotation is SxAnnotations){
return nil
}
// If no pin view already exists, create a new one.
let annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "pin")
annotationView.pinTintColor = .green
annotationView.animatesDrop = true
annotationView.canShowCallout = true
// Because this is an iOS app, add the detail disclosure button to display details about the annotation in another view.
let sxAnnotations = annotation as! SxAnnotations
let downloadURL = sxAnnotations.image!
storageRef.storage.reference(forURL: downloadURL).data(withMaxSize: 25 * 1024 * 1024, completion: { (data, error) -> Void in
let image = UIImage(data: data!)
annotationView.detailCalloutAccessoryView = UIImageView(image: image)
let rightAccessory = UILabel(frame: CGRect(x:0,y:0,width:50,height:30))
rightAccessory.text = sxAnnotations.name!
rightAccessory.font = UIFont(name: "Verdana", size: 10)
annotationView.rightCalloutAccessoryView = rightAccessory
})
return annotationView;
}
編輯:我知道有一個FUNC:
func mapView(mapView: MKMapView!, didSelectAnnotationView view: MKAnnotationView!)
{
//Pin clicked, do your stuff here
}
但我不能夠實現在
下載