How to send the data to
-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:
(id <MKAnnotation>)annotation {
method. Once please observe my code and give me the solution.
-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation: (id <MKAnnotation>)annotation {
static NSString *defaultPinID = @"com.invasivecode.pin";
MKAnnotationView *pinView =(MKAnnotationView *)[mapview dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
NSLog(@"pinData....%@",pinView);
if (pinView == nil){
pinView = [[MKAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:defaultPinID];
pinView.canShowCallout = YES;
pinView.enabled = YES;
pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[pinView setSelected:YES animated:YES];
pinView.image = [UIImage imageNamed:@"location.png"];
}
else{
}
return pinView;
}
If you add an annotation to your map and set the class that contains the code you showed above as the map's delegate, then iOS will call
viewForAnnotation
when ever it needs to redraw it