In meiner iPhone-Anwendung verwende ich MapKit mit MKMapView und benutzerdefinierter MKAnnotationView.
Das Problem ist, wenn Anmerkungen auf der Karte überlappen (in meiner app, Anmerkungen sind Fotos und diese Fotos überlappen können), und wenn Sie auf die Anmerkung tippen, die auf der Vorderseite erscheint, es ist eine andere Anmerkung (auf der Rückseite), die das Ereignis empfängt (scheint zufällig zu sein ).
Ich fand keine Möglichkeit, das Ereignis an die Front Anmerkung zu senden. Ich kann nicht glauben, dass dieser Fehler / Problem keine Lösung hat!
Z Ordnung und Reihenfolge der Anmerkungen überlappende Fragen auf Stackoverflow hat mir nicht so viel helfen.
Bitte jede Idee ist willkommen (auch schmutzige Lösungen)!
Hier einige meiner Code (nichts Besonderes, sehr häufig):
CustomAnnotation.h
@interface CustomAnnotation : NSObject <MKAnnotation> {
@private
CustomAnnotationView* view;
}
@property (nonatomic, retain) CustomAnnotationView* view;
@end
CustomAnnotation.m
@implementation CustomAnnotation
@synthetize view;
CustomAnnotationView.h
@interface CustomAnnotationView : MKAnnotationView {
}
@end
CustomAnnotationView.m
@implementation CustomAnnotationView
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
// Do something related to the annotation tapped
}
@end
Hauptklasse ... // Anmerkungen hinzugefügt und einige von ihnen überlappt mit anderen.
- (void)addAnnotation:(CustomAnnotation*)annotation {
[map addAnnotation:annotation];
}
...
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
NSString* identifier = getIdentifierFromAnnotation(annotation);
CustomAnnotationView* view;
if(!(view = (CustomAnnotationView*)[map dequeueReusableAnnotationViewWithIdentifier:identifier])) {
view = [[CustomAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier: identifier];
[(CustomAnnotation*)annotation setView:view];
[view release];
}
return view;
}













