views:

70

answers:

2

Hi,

I have annotations in a MKMapView with Callouts. In this Callouts there's a "Right-Arrow" Button. When clicking on it, I want to open a Detail View, an extra UIViewController with its own nib file etc. I use following code:

In my 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;


}

The button works, because when I give a NSLog inside the showDetais method, it's printed to the console. The problem is, that NOTHING happens. When clicking the button, it's like there isn't any button. There's no debug error or exception, just nothing.

the MapView header looks something like this:

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

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

Maybe someone of you can help me :)

Thanks!

A: 

Isn't detailViewController uninitialized? You don't show all your code but I believe you might have things a bit jumbled up preparing the view and pushing it.

Why are you declaring the detailViewController as an IBOUTlet?

Also, I think you might want/intend to do this on your detailViewController not in this controller: [self.navigationController setToolbarHidden:YES animated:NO];

Nick
A: 

Check if you have navigation controller for your viewController, if it is just a viewController then it cannot push a viewController because it does not have navigation controller in it.

RVN