I have some UI that I need to redraw based on changes to an MKMapView when the user pans or zooms the map.
Currently I am using a move event gesture recogniser and MKMapViewDelegate regionDidChangeAnimated messages to redraw my dependant UI. This is 90% of what I need.
The events I am missing are from the point the user lifts their finger (no more move events) to when the MKMapViewDelegate regionDidChangeAnimated message is fired. During that period the map slowly pans to a halt and my dependant UI is stuck with map tile content that is out of synch.
Is there a lower level API that will notify me when UIView (in this case MKMapView) content is redrawn?
Update
I tried creating a proxy MKMapView subclass that forwarded drawRect calls onto my supplied delegate. I get the first draw event but none of the subsequent ones, so this doesn’t help with my predicament.
IIRC, MKMapView is unfortunately not KVO-compliant for
@"region".You might hack you way setting up an
NSTimerinregionWillChangeAnimated, using it to refresh you UI during the scroll/pan/etc, and discarding it inregionDidChangeAnimated. Not quite elegant though, and it may not suit your needs if you need to be really fast.Alternatively, you may look for the
UIScrollViewin MKMapView’s subviews, and observe itstransform.(I haven’t tested any of these.)
In any case, I doubt that monitoring redraw events on a
MKMapViewwill be of any use :MKMapViewusesCATiledLayerto perform its drawing asynchronously, so you can’t even be sure when it’s done.Edit : This apparently does not work with iOS 6. Of course, this should not really come as a surprise. However, as far as I know, the delegate methods behave the same, so the OP’s problem is still real. I haven’t looked for an updated solution.