Swift Firebase在地图注释上下载注释图片点击
问题描述:
使用下面的代码,我改变了我的图钉外观并从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
}
但我不能够实现在
下载
答
如果您正在点击某个引脚,则有一个选项是使用代理功能来添加行为,如更改图像。
当销被轻敲,地图代表将接收该事件,并与
optional func mapView(_ mapView: MKMapView,
annotationView view: MKAnnotationView,
calloutAccessoryControlTapped control: UIControl)
处理