ViewForAnnotation is not being called

后端 未结 9 2008
悲哀的现实
悲哀的现实 2020-12-15 19:16

I am trying to make a map, where I can see my current location, and see what the street is called.

so far, I am able to put a pin on my map, but for some reason, I a

9条回答
  •  不知归路
    2020-12-15 19:46

    I had the same problem, as you mentioned. The delegate had been set to ViewController, but the viewForAnnotation selector was not being called. After some checks, I realized if you do not call addAnotation in the main thread, mapView would not call viewForAnnotation, so following update resolved my problem:

    Before:

    [_mMapView addAnnotation:marker];
    

    After:

    dispatch_async(dispatch_get_main_queue(), ^{
         [_mMapView addAnnotation:marker];
    });
    

提交回复
热议问题