你好我的问题是这段代码:
<div data-role="page" id="page1" style="background: none;">
<div id='main-contents'>
<div id='navigation-drawer'>
<ul id="list">
<li class="menuItem" id="helpBtn">
<p>Help</p>
</li>
</ul>
</div>
</div>
似乎无法正常工作。问题是,即使我触摸标题而不是按钮,也会始终调用func mapView(mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
if control is UIButton {
if (control as! UIButton).buttonType == .DetailDisclosure{removeAnnotation()}
else{performSegueWithIdentifier("edit", sender: nil)}
}
}
。我该如何解决这个问题?
答案 0 :(得分:0)
在
中添加信息右键func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
// add button here, i.e.
let btn = UIButton(type: .Custom)
btn.frame = CGRectMake(0, 0, 30, 30)
btn.setImage(UIImage(named: "info"), forState: .Normal)
annotationView.rightCalloutAccessoryView = btn
// ... other required code
}
然后在
内func mapView(mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
if control == view.rightCalloutAccessoryView {
print("Tap")
}
}