I have a task to develop the application with map kit and web service of asp.net.
My problem is when I got the location from the web service. And according that location the pin is also setting to it’s located place.
But my problem is I have given the pin pop up on it. it is working when the user click on the pin it will show the pop up. but the pop up on the pin is not working. I have included all related code for the pin and pin pop up. but it is not working when I am clicking on that pin.
I am also adding the code to display the pin on map and message which I have given.
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
NSLog(@"Controll comes here");
if (annotation == mapView.userLocation)
return nil;
MKPinAnnotationView *pin = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier: @"asdf"];
if (pin == nil)
pin = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier: @"asdf"] autorelease];
else
pin.annotation = annotation;
pin.userInteractionEnabled = YES;
UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[disclosureButton setFrame:CGRectMake(0, 0, 30, 30)];
pin.rightCalloutAccessoryView = disclosureButton;
pin.pinColor = MKPinAnnotationColorRed;
pin.animatesDrop = YES;
[pin setEnabled:YES];
[pin setCanShowCallout:YES];
return pin;
}
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
NSString *strTitle = [NSString stringWithFormat:@"%@",[lines objectAtIndex:i]];
NSMutableDictionary *d;
NSMutableArray *temp=[NSArray arrayWithArray:lat];
// NSArray *temp=[NSArray arrayWithArray:[NSArray arrayWithArray:[reports objectAtIndex:0]]];
for (int k = 0; k< i -1; k++)
{
d = (NSMutableDictionary*)[temp objectAtIndex:k];
NSString *strAddress = [NSString stringWithFormat:@"%@",[d valueForKey:@"comments"]];
if([strAddress isEqualToString:strTitle]) {
[self presentModalViewController:self.nxtDetailsVCtr animated:YES];
[self.nxtDetailsVCtr.lblDetail setText:strAddress];
break;
}
}
}
For that u need to implement the below code for that