开发者

Is there a Mapkit Annotation event when the pin is done animating?

I am having some issues with my Mapkit and userlocation events. I need to call a method when the us开发者_JS百科er'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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜