Question

I've added some MKPolygons to my MKMapView and they are displayed just fine by the MKMapView. If I now enable the userLocation for this MKMapView and the user grants permission for his location, no delegates are called and no overlays are drawn. After the next viewDidLoad the delegates work fine again and all the overlays are displayed.

So the problem only seems to appear, if the user is asked to grant permission for his location.

I hope somebody has an explanation/solution for this strange behavior, thanks.

Update

As I found out, it has nothing todo with the user location. Somehow the MKMapView is not calling it's delegates for drawing the overlays, but only if it's the initial view during the first app start. After that everthing works.

Était-ce utile?

La solution

Simply move the setup code into its own method and call that both from viewDidLoad and one of the user tracking delegate methods like mapView:didChangeUserTrackingMode:animated: or mapViewWillStartLocatingUser:.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top