我将Swift与iOS 9配合使用。无论我选择哪种按钮类型,除了ContactAdd之外,只显示信息图标。我正在尝试在mapview中为标注的右侧获取一个DetailDisclosure图标。这是代码:

    let rightButton = UIButton(type: UIButtonType.DetailDisclosure);
    rightButton.addTarget(self, action: "buttonTapped:", forControlEvents: UIControlEvents.TouchUpInside)
    annotationView.rightCalloutAccessoryView = rightButton;

最佳答案

您创建了图钉了吗?尝试将按钮.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

10-07 19:05