Search code examples
xcodeiosmkmapviewmkannotationview

MapKit MapView Annotations overlapping on a real device


I have the problem depicted in the image when testing my app on a real device (iPhone 3G, 3.1.3). It is fine in the simulator (xcode 3 with ios 4.1 sdk). sorry, can't post images yet, this is my first question here.

https://i.sstatic.net/Ct4on.jpg

I have the following code in the implementation of the annotation:

- (id)initWithLocation:(CLLocationCoordinate2D)coord {
self = [super init];
if (self) {
    coordinate = coord;
}
return self;
}

And this is part of the header file:

@interface MyAnnotation : NSObject <MKAnnotation>

And this is where I create a new one (inside a loop):

MyAnnotation *theAnnotation = [[MyAnnotation alloc]  initWithLocation:theCoordinate];
theAnnotation.title = [single objectForKey:@"address"];
theAnnotation.objID = [single objectForKey:@"id"];

[self.mapView addAnnotation:theAnnotation];
[theAnnotation release];

Any ideas about this? I don't know what to look :/


Solution

  • You could try to bring the (annotation)view to the front, when tapping on it.

    So, when someone taps on an annotation, you should call [[self superview] bringSubviewToFront:self];

    Best, Christian