0

i wanted to display the detail view after tapping the right button on the annotation of mapview in xcode but i could not get the view to display , my code:

- (void)showDetails:(id)sender
{
  [self.navigationController setToolbarHidden:YES animated:NO];

[self.navigationController pushViewController:self.detailViewController animated:YES];

}



- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
static NSString* BridgeAnnotationIdentifier = @"bridgeAnnotationIdentifier";

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

UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
NSLog(@"%@",rightButton);
[rightButton addTarget:self
                action:@selector(showDetails:)
      forControlEvents:UIControlEventTouchUpInside];
customPinView.rightCalloutAccessoryView = rightButton;
return customPinView;//[kml viewForAnnotation:annotation];
}

The showDetails method gets called but cannot push the detailViewController to the top ,

[self.navigationController pushViewController:self.detailViewController animated:YES];

this code should have pushed detail view to the top and displayed the detailView but it does not please ,

any help would be greatly appreciated , what i wanted to do is when anybody taps on the right button of annotation on the mapview ,i wanted to display a detail view , thanking you in advance..

jarus
  • 1,853
  • 11
  • 44
  • 76
  • You may find useful information in this question http://stackoverflow.com/questions/8285153/regarding-apples-kmlviewer-placemarkdescription-and-annotation-subtitle – Hari Mar 21 '12 at 22:56

2 Answers2

1

There is no target/action required, there is a delegate method that gets called when the callout accessory view is tapped: mapView:annotationView:calloutAccessoryControlTapped:

Scott Berrevoets
  • 16,921
  • 6
  • 59
  • 80
  • ok, i have a detailViewController how can i display that view when the rightbutton is tapped . – jarus Mar 08 '12 at 08:35
0

Thank you , for your help i am able to open the detailViewController by changing my showDetails method

- (void)showDetails:(id)sender
    {
      detailViewController *dvController = [[detailViewController alloc] initWithNibName:nil bundle:nil];
      [self presentModalViewController:dvController animated:YES];
      [dvController release];
      dvController = nil;
    }
jarus
  • 1,853
  • 11
  • 44
  • 76