tags:

views:

196

answers:

1

I am having some issues with my Mapkit and userlocation events. I need to call a method when the user's location is found, however, using [locationManager startUpdatingLocation]; causes the method to call too early for what I am trying to do.

Ideally, I would like to make a call once the animation of the user location's pin is completed. Is there any way to watch for that?

+1  A: 

In the delegate of your locationManager (which conforms to the CLLocationManagerDelegate protocol), implement your method call inside:

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation;

This will be called once the location is resolved. You may want to make sure it is within your desired accuracy tolerances before taking action:

if (newLocation.accuracy <= locationManager.desiredAccuracy ){

You may want to perform your action after a delay to allow the animation for the current location to complete. Apple seems to typically uses between 0.5 and 0.25 for animation durations.

Chip Coons