*问题是:我如何制作按钮(按下时)打开与销钉上所选商店相对应的链接?
我有一系列商店(针脚)(我为它创建了一个类,并为pinAnnotation创建了一个类)
这里我正在创建按钮和图钉
func mapView(_ mapView:MKMapView,viewFor annotation:MKAnnotation) - > MKAnnotationView? {
let identifier = "annotationReusedId"
var anView = myMapView.dequeueReusableAnnotationView(withIdentifier: identifier)
如果anView == nil {
anView = MKAnnotationView(annotation: annotation, reuseIdentifier: identifier)
} else {
anView!.annotation = annotation
}
anView!.image = UIImage(named: "upcycled")
anView?.frame = CGRect(x: 0, y: 0, width: 35, height: 35)
anView!.backgroundColor = UIColor.clear
anView!.canShowCallout = true
let rightButton = UIButton(type: .infoLight)
rightButton.tag = annotation.hash
rightButton.addTarget(self, action:#selector(openLinkInstagram), for: .touchUpInside)
//anView!.animatesDrop = true
anView!.canShowCallout = true
anView!.rightCalloutAccessoryView = rightButton
return anView
}
这里是用于打开链接的函数
func openLinkInstagram(){
}