MKMapView Annotation Callout-Button in die Detailansicht?

Habe ich Anmerkungen in einer MKMapView mit Legenden. In dieser Anzeige gibt es ein "Rechts-Pfeil" - Taste. Wenn man darauf klickt, möchte ich eine Detailansicht zu öffnen, eine zusätzliche UIViewController mit eigene nib-Dateien etc. Ich benutze folgenden code:

In meinem MapViewController:

- (void)showDetails:(id)sender {
    //the detail view does not want a toolbar so hide it
    [self.navigationController setToolbarHidden:YES animated:NO];
    NSLog(@"pressed!");
    [self.navigationController pushViewController:self.detailViewController animated:YES];
    NSLog(@"pressed --- 2!");
}

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(Annotation *) annotation {

    if(annotation == map.userLocation) return nil;

    static NSString* AnnotationIdentifier = @"AnnotationIdentifier";


    MKPinAnnotationView* customPinView = [[[MKPinAnnotationView alloc]
                                           initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] autorelease];
    customPinView.pinColor = MKPinAnnotationColorRed;
    customPinView.animatesDrop = YES;
    customPinView.canShowCallout = YES;

    UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    [rightButton addTarget:self
                                    action:@selector(showDetails:)
                forControlEvents:UIControlEventTouchUpInside];
    customPinView.rightCalloutAccessoryView = rightButton;

    UIImageView *memorialIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"googlemaps_pin.png"]];
    customPinView.leftCalloutAccessoryView = memorialIcon;
    [memorialIcon release];

    return customPinView;


}

Die Schaltfläche funktioniert, weil wenn ich eine NSLog innerhalb der showDetais Methode, es ist auf der Konsole ausgegeben. Das problem ist, dass NICHTS passiert. Beim Klick auf den button, es ist, wie es gibt nicht eine beliebige Taste drücken. Es gibt keine debug-Fehler oder einer exception, einfach nichts.

den MapView-header wie folgt aussieht:

@interface MapViewController : UIViewController <MKMapViewDelegate> {
    MKMapView *map;
    NSMutableDictionary *dictionary;
    EntryDetailController *detailViewController;
}

@property (nonatomic,retain) IBOutlet MKMapView *map;
@property (nonatomic,retain) IBOutlet EntryDetailController *detailViewController;

Vielleicht jemand von Euch kann mir helfen 🙂

Dank!

InformationsquelleAutor Tronic | 2010-06-14
Schreibe einen Kommentar