我在iOS 9中使用Swift。无论我选择什么按钮类型,ContactAdd除外,仅显示信息图标。我试图在mapview中为标注的右侧获取DetailDisclosure图标。这是代码:
let rightButton = UIButton(type: UIButtonType.DetailDisclosure);
rightButton.addTarget(self, action: "buttonTapped:", forControlEvents: UIControlEvents.TouchUpInside)
annotationView.rightCalloutAccessoryView = rightButton;
答案 0 :(得分:1)
你创建了一个针吗?尝试将按钮.DetailDisclosure
添加到pinView
var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as?
pinView!.rightCalloutAccessoryView = UIButton.buttonWithType(.DetailDisclosure) as UIButton
<强>更新强> 这对我有用
let identifier = "pin"
var view: MKPinAnnotationView
view = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier)
view.canShowCallout = true
view.calloutOffset = CGPoint(x: -5, y: 5)
view.rightCalloutAccessoryView = UIButton(type: .DetailDisclosure) as UIView
答案 1 :(得分:0)
@user2893289
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView?
{
let annotationView = MKPinAnnotationView(annotation: noseyesAnnotation, reuseIdentifier: "pin")
annotationView.pinTintColor = noseyesAnnotation.color
annotationView.canShowCallout = true
let rightButton = UIButton(type: UIButtonType.DetailDisclosure);
annotationView.rightCalloutAccessoryView = rightButton;
return annotationView
}