Autosize annotation.title [дубликат]

var funcs = [];
for (var i = 0; i < 3; i++) {      // let's create 3 functions
  funcs[i] = function(param) {          // and store them in funcs
    console.log("My value: " + param); // each should log its value.
  };
}
for (var j = 0; j < 3; j++) {
  funcs[j](j);                      // and now let's run each one to see with j
}
2
задан Richie 12 June 2016 в 09:11
поделиться

1 ответ

Я понял, я добавил метку в viewForAnnotation, и она просто сработала

¯ \ _ (ツ) _ / ¯

func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {

    if annotation is MKUserLocation {
        //return nil so map view draws "blue dot" for standard user location
        return nil
    }

    let reuseId = "pin"

    var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? MKPinAnnotationView
    if pinView == nil {
        pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
        pinView!.canShowCallout = true
    }
    else {
        pinView!.annotation = annotation
    }

    //THIS IS THE GOOD BIT
    let subtitleView = UILabel()
    subtitleView.font = subtitleView.font.fontWithSize(12)
    subtitleView.numberOfLines = 0
    subtitleView.text = annotation.subtitle!
    pinView!.detailCalloutAccessoryView = subtitleView


    return pinView
}
8
ответ дан Richie 26 August 2018 в 10:46
поделиться
Другие вопросы по тегам:

Похожие вопросы: