0

I'm working on an app that uses MKMapView to track the user's progress, and I thought I would adopt the iOS 7 Apple Maps method of using a callout button to start the tracking. However in my case the user stays on the same view, so I need to modify the button to indicate that tracking is already in progress.

I created a simple animation and added it to the button's layer when the button is tapped. Works fine. The problem comes in if the user dismisses and then brings back the callout. Despite code in didSelectAnnotation to put the animation back on the layer, the view that's presented doesn't have the animation in place. According to this post:

UIButton Not Loading Properly For MKAnnotationView

This is because the annotation view is prepared before didSelectAnnotation is called. It must be prepared well in advance because viewForAnnotation, the other place I could do this, is not being called when the callout is re-displayed.

I can't think of any way to make this work now that I know that, but I'm hoping that someone out there will have the answer.

Edit:

I tried adding the animation to the button in viewForAnnotation and then pausing it, intending to resume it when the button is tapped. However, when the button is tapped it no longer has an animation on it - mapkit seems to have stripped it away. It is there in didSelectAnnotation, but somewhere between the two it disappears.

I can add the animation to the whole MKAnnotationView, but that does not behave as intended - the entire thing animates, including the callout, which looks really strange. Also, pausing the animation on this view interferes with displaying the callout.

All I'm trying to do here is make the button image "pulse" to indicate that it has already been tapped and that tracking is in progress, while leaving it looking tappable so the user knows they can tap it again to stop tracking.

I have a feeling I'm SOL here… please someone, prove me wrong!

Community
  • 1
  • 1
janineanne
  • 585
  • 7
  • 17

1 Answers1

0

The answer is to use a completely custom callout. I used the following posts and sample code as a guide, and was able to get it working.

http://blog.asynchrony.com/2010/09/building-custom-map-annotation-callouts-part-1/ http://blog.asynchrony.com/2010/09/building-custom-map-annotation-callouts-part-2/

janineanne
  • 585
  • 7
  • 17