5

To move custom annotations in my MKMapView class, I remove all annotations first and add them (which are placed in new locations) again every second. It was perfectly working on iOS 3 but when I updated my OS and XCode to version 4.0, the annotations blink instead of having the smooth movement they used to have in previous version.

How can I keep this smooth movement?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Pooya
  • 399
  • 2
  • 13
  • On a hunch, what happens if you re-add the annotation without removing it? If you're lucky MKMapView will notice that you're trying to add the same thing twice and reload the coordinate... – tc. Oct 02 '10 at 14:28
  • I tried, but if I reuse the same annotations, change latitude, longitude values and add them (again) to MKMapView, the objects won't move at all. It seems that once an annotation is added to a MKMapView it won't be updated. – Pooya Oct 03 '10 at 04:39

1 Answers1

0

This is probably a bad workaround and more effort than needed, but it should work:

  1. Get a UIImage by rendering the old MKMapView to a bitmap: Rendering UIView with its children
  2. Display that UIImage over your map view.
  3. Change your annotations (user doesn't see the blink because the image is covering the map view)
  4. Once the blink is done, quickly fade the image out. Not a perfect transition, but better than nothing.
Community
  • 1
  • 1
igul222
  • 8,557
  • 14
  • 52
  • 60
  • This could be a good solution depends on the application. Unfortunately, in mine, user should be able to pan/zoom the map while the objects are moving. So the above solution may cause serious performance concerns. – Pooya Oct 03 '10 at 04:44
  • Actually I try to develop a location-based game in which user can gather some coins, escape from moving monsters,.... – Pooya Oct 03 '10 at 04:45