0

我在 iOS 9 中使用 Swift。无论我选择什么按钮类型,除了 ContactAdd,只会呈现信息图标。我正在尝试在地图视图中获取标注右侧的 DetailDisclosure 图标。这是代码:

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

2 回答 2

1

你创建了一个图钉吗?尝试将按钮添加.DetailDisclosurepinView

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
于 2015-11-29T23:54:07.947 回答
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
}
于 2015-12-01T01:30:40.330 回答