Multiple annotation callouts displaying in MKMapView

后端 未结 3 1241
醉话见心
醉话见心 2020-11-27 23:05

Is it possible to open simultaneously more then one callout?

The code:

- (void)mapViewDidFinishLoadingMap:(MKMapView *)theMapView {
    for (id

        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-27 23:36

    Since iOS 11, Apple added new annotation view called MKMarkerAnnotationView.

    In func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?, when you dequeue the annotation view, make sure you cast it as MKMarkerAnnotationView (e.g. var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier) as? MKMarkerAnnotationView), and set view's attributes titleVisibility and subtitleVisibility to .visible.

提交回复
热议问题