【发布时间】:2016-02-16 00:47:18
【问题描述】:
我尝试给我的注释 3 个按钮(2 个已经完成),图像上的按钮 1 和按钮 2,现在我想在单击按钮 3 后执行一个 segue 无论如何都可以这样做吗?
要创建此注释,我的代码如下所示
if (annotation is CustomPointAnnotation2){
let reuseId = "ParseAnno"
var anView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
if anView == nil {
anView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
anView!.canShowCallout = true
}
else {
anView!.annotation = annotation
}
let buttonSignIcon1 = UIButton()
buttonSignIcon1.frame.size.width = 50
buttonSignIcon1.frame.size.height = 52
buttonSignIcon1.backgroundColor = UIColor(red: 0, green: 0.373, blue: 0.694, alpha: 1.0)
buttonSignIcon1.setImage(UIImage(named: "annotationButtonLeft"), forState: .Normal)
anView!.leftCalloutAccessoryView = buttonSignIcon1
let buttonSignIcon = UIButton()
buttonSignIcon.frame.size.width = 50
buttonSignIcon.frame.size.height = 52
buttonSignIcon.backgroundColor = UIColor(red: 1, green: 0, blue: 0, alpha: 1.0)
buttonSignIcon.setImage(UIImage(named: "annotationButtonRight"), forState: .Normal)
anView!.rightCalloutAccessoryView = buttonSignIcon
let x = annotation as! CustomPointAnnotation2
anView!.image = UIImage(named:x.imageName)
return (anView)
点击我使用的“运行功能”
func mapView(mapView: MKMapView!, annotationView: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
if control == annotationView.leftCalloutAccessoryView {
print(annotationView.annotation?.title)
print(annotationView.annotation?.coordinate)
self.Destination_fromAnnotation = (annotationView.annotation?.coordinate)!
self.getDirections()
}
.
.
.
有没有办法让按钮“3”也有一个动作?
【问题讨论】:
标签: ios swift dictionary annotations