iOS - не удается получить DetailDisclosure для кнопки в выноске

Я использую Swift с iOS 9. Независимо от того, какой тип кнопок я выбираю, кроме ContactAdd, только и отображается информационный значок. Я пытаюсь получить значок DetailDisclosure для правой стороны выноски в виде карты. Вот код:

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

3 ответа

Решение

Вы уже создали пин-код? Попробуйте добавить кнопку .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
@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
}

@user2893289 Это все еще не работает.

Я попытался просто создать кнопку как подробное раскрытие и добавить ее к своему представлению, и раскрытие не показывалось; вместо этого отображается значок информации. Вот простой код:

let btnview = UIButton(type: .DetailDisclosure)

self.view.addSubview(btnview)
Другие вопросы по тегам