I need to accurately track the centerCoordinate
of an MKMapView
while the user zooms/pans the map, i.e. between the regionWillChangeAnimated:
and regionDidChangeAnimated:
events.
I've tested the following approaches by trying to lock an MKAnnotation
to the map's center. Unfortunately, none of them work well enough:
Using
UIPanGestureRecognizer
(as described here): this works quite well while the display is touched, but doesn't update while the map is animated after the touch gesture is complete. In addition, the updates lag behind the actualcenterCoordinate
.Using
UIScrollViewDelegate
I subclassed MKMapView to receive thescrollViewDidScroll:
event. This worked, but the event isn't triggered on every scrolling increment, leading to jerky updates.Using KVO Notifications: following this pattern, I tried to observe the mapview's
centerCoordinate
. It works for theuserLocation
, but the notifications don't seem to be sent forcenterCoordinate
.
Any ideas on how to track centerCoordinate
effectively and accurately?
KVO seemed like the best bet. Is there a trick to making it work with MKMapView
's centerCoordinate
property?