An old question that I would like to answer in my own way. I had a question similar to a question. I just needed to make a web service call, passing the user location as a GET parameter, when my MapView ViewController / Screen was loaded and the user location obtained by mapView. Then it made sense to call the web service as part of the didUpdateUserLocation delegation method. At first, I didn’t notice the wrong behavior, because everything seemed to work correctly, but for some reason, sometimes when the mapView screen opens, the user's blue dot is displayed, but the map will not “zoom in” and none of them were called by UpdateUserLocation, nor mine internal web service explicitly. After a few seconds, looking at the screen, the map will "zoom in" and the didUpdateUserLocation / web service is called. Some small glitch that I thought didn’t matter. Now my detail-oriented developer was still disappointed, and after several weeks of thinking about it, I decided to take action on this. Stackoverflow did not give me an answer right away, but nonetheless pointed me in the right direction. And there was a criminal: The sequence of calls! Madening, but it made sense as soon as I understood everything. I knew that in order to see the blue dot and get the location of the user, I had to tell mapView to do this. So, as a lover of Interface Builder, I correctly configured my mapView in IB, that is, I checked the field: "User location", easily. Then, after carefully reading the mapView documentation, I realized that my ViewController must comply with MKMapViewDelegate, made a deal. As I said, everything seemed to work fine, the blue dot will be displayed immediately, but sometimes the "enlargement" of the card will take several seconds ... well, my iPhone is already 3 years old, everything is slow, I "I'm dealing with slowness. .. Then I read this post ( https://stackoverflow.com/a/3/985616/ ... ) and everything became clear. In my case, using IB, there was a sequence of calls:
- User flag set to IB
- In viewDidLoad, call:
mapView.delegate = self
While the sequence of calls should be:
- User location flag is NOT set to IB (this is important)
mapView.delegate = selfmapView.showsUserLocation = true
And that changes EVERYTHING. Instead of sometimes scaling a mapView, and sometimes after a few seconds, mapView now scales immediately when the screen opens and the doUpdateUserLocation / web service is called.
Now a little more about why, it still "sometimes" worked. This is due to the fact that the location of my iPhone was sometimes updated immediately after loading the map screen, and sometimes not :-). I have to say that in addition to the stackoverflow message mentioned above, what helped me also tested my application in Simulator, since I needed to use a gpx file with an obviously static location coordinate, the unpredictable behavior that I described was then systematic.
So as much as I like Interface Builder, I may have to rethink how unconditional this love is.
PS: I know that this post is old and my answer is not entirely related to the @Patrick Perini problem, but I want him to help others, and that he could respond to @Patrick Perini's conclusion that the error was to blame, when she is not. Thanks for reading this blog post :-)