I have a map view, and there are 10 storage locations whose data comes through webservice. I just want to click on my detailed view to show the address, phone number and other information about this store.
I need to transfer data to mine detailviewwhen the user tapped or touched inside the annotation on mapkit. I mapviewhave 10 annotations in mine , and first I want to know how I can understand or how to get the annotation id that the annotation is clicked on?
this is a contact return method
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]]) return nil;
static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
MKPinAnnotationView* pinView = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
pinView.animatesDrop=YES;
pinView.canShowCallout=YES;
pinView.pinColor=MKPinAnnotationColorPurple;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
pinView.rightCalloutAccessoryView = rightButton;
return pinView;
}
- (IBAction)showDetails:(id)sender{
NSLog(@"Annotation Click");
[[mtMap selectedAnnotations]objectAtIndex:0];
magazaDetayViewController *detail = [[magazaDetayViewController
alloc]initWithNibName:@"magazaDetayViewController" bundle:nil];
detail.sehir=@"";
detail.magazaAdi=@"";
detail.adres=@"";
detail.telefon=@"";
detail.fax=@"";
[self.navigationController pushViewController:detail animated:YES];
}
If I can just get the annotation index with a click, I cannot populate the detailed properties with my array. if this is not possible, is there any other way to do this?
source